HOW TO RETRIEVE A VISITOR'S IP ADDRESS

조회 수: 5 (최근 30일)
mohammad ibrahim
mohammad ibrahim 2021년 8월 1일
답변: Hari 2024년 11월 13일 3:08
How can I retrieve the IP address of visitors to my web app using MATLAB ?
for example in .NET, we can use:
public string IpAddress()
{ string strIpAddress; strIpAddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (strIpAddress == null)
{ strIpAddress = Request.ServerVariables["REMOTE_ADDR"]; }
return strIpAddress; }
thank you

답변 (1개)

Hari
Hari 2024년 11월 13일 3:08
Hi mohammad,
I understand that you want to retrieve the IP address of visitors to your web application using MATLAB, similar to how it's done in .NET.
I assume you have a MATLAB-based web application, possibly using MATLAB Web App Server or MATLAB Production Server.
Here are some of the way you can try out.
  1. Use MATLAB Web App Server: If you're using MATLAB Web App Server, you can access request headers to retrieve the IP address. However, direct access to server variables like in .NET is not available in MATLAB. You might need to handle this on the server side using a proxy or middleware to pass the IP address to your MATLAB code.
  2. Capture IP Address via Middleware: Implement a middleware layer in your web server (like Apache or Nginx) to capture the IP address and pass it as a parameter to your MATLAB function. This approach requires configuring your server to include the IP address in requests to MATLAB.
  3. Use MATLAB Production Server: If using MATLAB Production Server, you can configure request handling to include custom headers with the IP address. This involves setting up your server to capture and forward the IP address to your MATLAB function.
Refer to the documentation of MATLAB Web App Server for deployment details: https://www.mathworks.com/help/webappserver/
Refer to the documentation of MATLAB Production Server for request handling: https://www.mathworks.com/help/mps/
Hope this helps!

카테고리

Help CenterFile Exchange에서 Call Web Services from MATLAB Using HTTP에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by