Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Client IP and TcpListener/TcpClient

0 views
Skip to first unread message

Jeffrey Drake

unread,
Oct 8, 2001, 3:56:06 PM10/8/01
to
How would I be able to get the IP from either of TcpListener/Client?

I know about the Socket object's RemoteEndPoint, but I don't know how to get
a Socket object out of TcpListener or Client (I am using AcceptTcpClient in
TcpListener, not the AcceptSocket).

Regards,
Jeffrey Drake


Saurabh Nandu

unread,
Oct 9, 2001, 11:50:35 PM10/9/01
to
try this
TcpClient myClient = serverListner.AcceptTcpClient();
Socket socks = myClient.Client ;
.... I guess you know the rest :)

Regards,
Saurabh Nandu
http://www.MasterCSharp.com
Master C#, the easy way...

"Jeffrey Drake" <jp...@home.com> wrote in message
news:u9$OeMDUBHA.1636@tkmsftngp05...

Michael Malinak

unread,
Oct 10, 2001, 8:34:05 AM10/10/01
to
When I try this with a UdpClient I get:
"'System.Net.Sockets.UdpClient.Client' is inaccessible due to its protection
level"


"Saurabh Nandu" <sau...@UltraApps.com> wrote in message
news:eaJ9M1TUBHA.1712@tkmsftngp03...

Patrick Steele

unread,
Oct 15, 2001, 9:15:25 PM10/15/01
to
In article <eaJ9M1TUBHA.1712@tkmsftngp03> (from Saurabh Nandu
<sau...@UltraApps.com>),

> try this
> TcpClient myClient = serverListner.AcceptTcpClient();
> Socket socks = myClient.Client ;
> .... I guess you know the rest :)

That won't work as "Client" is a protected member. You could either
subclass the TCPClient class and expose the RemoteEndPoint yourself, or
you could use reflection to access the Client member.

--
Patrick Steele
Microsoft .NET MVP

Saurabh

unread,
Oct 16, 2001, 12:04:10 PM10/16/01
to
I realized I was a short-sited there to reply ... before checking the 'private' access modifier :)

Regards,
Saurabh Nandu


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

0 new messages