networking help

L

lucifer

Code:

IPAddress iadd =IPAddress.Parse("192.168.1.2");
IPEndPoint ipe = new IPEndPoint(iadd, port);
Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream
,ProtocolType.Tcp);
sock.Bind(ipe);
sock.Listen(32);
sock.Accept();
sock.Connect()// problem i dont know remote ip address nor can i hard
code it
web(sock);
sock.Shutdown(SocketShutdown.Both);
sock.Close();


how can i find about the ip address of remote client
 
N

Nicholas Paldino [.NET/C# MVP]

lucifer,

When you call the Accept method, it returns a Socket instance
representing the connection. On that instance, access the RemoteEndPoint
property to get the EndPoint which represents the ip address of the remote
client.

Hope this helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top