TCPClient and Get the IPAddress of the Client

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How Can I get the IPAddress of the client connecting to my server
I understand that it is available after using AcceptSocket, but I already wrote everything with AcceptTCPClient
I just want the IPAddress for Logging purposes

Thanks
bria

sscsin
..com
 
Hi,

The TcpClient class has a Client property, this will give you the underlying
Socket object on which you can call RemoteEndPoint.

Hope this helps

--
Chris Taylor
http://dotnetjunkies.com/WebLog/chris.taylor/
BrianG said:
How Can I get the IPAddress of the client connecting to my server?
I understand that it is available after using AcceptSocket, but I already
wrote everything with AcceptTCPClient.
 
To clarify, you'll have to build a class that extends TcpClient, and then do
the work to expose the member data outside the class.
 
When I had to do this, I forwent (forgoed?) the derived class and just used
reflection to get the "Client" property.

Chris
 
I was blaming the AcceptSocket for my own stupidity. Once I realized that the code ws broken both ways, I went with AcceptSocket and all is working.

Thanks for the help and ideas.
 
Back
Top