Re: TcpClient and IP
From: Tim Jarvis (tjarvis_at_NoSpamForMe.com)
Date: 03/02/04
- Next message: Robert Jacobson: "Alternative conditional operator"
- Previous message: v-jetan_at_online.microsoft.com: "Re: Any Tool that can explore DLL"
- In reply to: user_at_domain.invalid: "TcpClient and IP"
- Next in thread: Tim Jarvis: "Re: TcpClient and IP"
- Reply: Tim Jarvis: "Re: TcpClient and IP"
- Reply: Stephen Richardson: "Re: TcpClient and IP"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 02 Mar 2004 00:02:08 -0800
user@domain.invalid wrote:
> Hello
> How can i read IP of incoming connection when i have TcpClient for
> that connection ?
>
> Thanx
you can get that from a socket object the RemoteEndPoint propery
returns a IPEndPoint structure you can use.
The slightly trick bit is getting the socket object, there are 2
options..
1./ The TcpClient class has a Socket property, but it is protected, so
you could create a custom class that derives from it.
2./ You can use the TcpListener.AcceptSocket method which returns a
socket. (you can create a network stream from the socket that you can
use to create BinaryReader and binaryWriter objects)
then you simply use the socket i.e.
(IpEndPoint)socket.RemoteEndPoint.Address.ToString();
Hope that Helps.
Regards Tim.
- Next message: Robert Jacobson: "Alternative conditional operator"
- Previous message: v-jetan_at_online.microsoft.com: "Re: Any Tool that can explore DLL"
- In reply to: user_at_domain.invalid: "TcpClient and IP"
- Next in thread: Tim Jarvis: "Re: TcpClient and IP"
- Reply: Tim Jarvis: "Re: TcpClient and IP"
- Reply: Stephen Richardson: "Re: TcpClient and IP"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|