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