Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/314.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何使用socket编程c获取客户端IP#_C#_Sockets - Fatal编程技术网

C# 如何使用socket编程c获取客户端IP#

C# 如何使用socket编程c获取客户端IP#,c#,sockets,C#,Sockets,当我们请求访问文件传输时,是否有人知道如何使用套接字编程获取客户端IP地址??我使用的是C#。套接字。LocalEndPoint或套接字。RemoteEndPoint应该会起作用,这取决于您是否是客户端。假设您有一个,在呼叫后您会收到一个。在此套接字上,您可以调用,以获取实际IP地址: // Using the RemoteEndPoint property. Console.WriteLine ( "I am connected to " + IPAddress.Parse (((IPEndP

当我们请求访问文件传输时,是否有人知道如何使用套接字编程获取客户端IP地址??我使用的是C#。

套接字。LocalEndPoint
套接字。RemoteEndPoint
应该会起作用,这取决于您是否是客户端。

假设您有一个,在呼叫后您会收到一个。在此套接字上,您可以调用

,以获取实际IP地址:

// Using the RemoteEndPoint property.
Console.WriteLine (
"I am connected to " + IPAddress.Parse (((IPEndPoint)s.RemoteEndPoint).Address.ToString ()) + 
"on port number " + ((IPEndPoint)s.RemoteEndPoint).Port.ToString ());

// Using the LocalEndPoint property.
Console.WriteLine (
"My local IpAddress is :" + IPAddress.Parse (((IPEndPoint)s.LocalEndPoint).Address.ToString ()) +
"I am connected on port number " + ((IPEndPoint)s.LocalEndPoint).Port.ToString ());

摘自网站:

您是在谈论获取您当前所在机器的IP地址,还是请求的远程计算机的IP地址?基本上,我正在为Windows mobile开发一个应用程序,我们使用xml文件在其中存储信息。所以,当Windows mobile应用程序请求保存以在服务器中保存文件时,我希望我的Windows应用程序为该Windows mobile应用程序创建一个文件夹,并将所有文件保存在该文件夹中。