Home All Groups Group Topic Archive Search About

Limit socket connection to local machine

Author
23 Oct 2006 4:58 PM
Bob
What is the best way to limit a socket connect to the local machine

Is this correct & best way to do this?

mySocket = s.Accept();
if(mySocket.LocalEndPoint != mySocket.RemoteEndPoint)
    mySocket.Close();



Bob

Author
23 Oct 2006 7:06 PM
Vadym Stetsyak
Hello, Bob!

if you want to only accept local connections, then you can bind socket to
local endpoint ( loopback ).

socket.Bind(new IPEndPoint(IpAddress.Loopback, somePort));

You wrote  on Mon, 23 Oct 2006 12:58:06 -0400:

B> What is the best way to limit a socket connect to the local machine

B> Is this correct & best way to do this?

B> mySocket = s.Accept();
B> if(mySocket.LocalEndPoint != mySocket.RemoteEndPoint)
B>     mySocket.Close();



B> Bob



--
With best regards, Vadym Stetsyak.
Blog: http://vadmyst.blogspot.com

AddThis Social Bookmark Button