Socket and local IP address

M

Marty

Hi,

When we create a new socket and make it connect to a remote endpoint,
how can we tell to the socket to use a specific IP address on the local
computer, when multiples IPs are enabled.

Thank you
Marty
 
T

Tom Shelton

Hi,

When we create a new socket and make it connect to a remote endpoint,
how can we tell to the socket to use a specific IP address on the local
computer, when multiples IPs are enabled.

Thank you
Marty

Use the sockets bind method befor you call Connect.

mySocket.Bind (New IPEndPoint (MyIPAddress, 0))
mySocket.Connect (.....)

The 0 for the port lets the network service provider assign the local
port - but if you want the local endpoint to have a specific port as
well as IP, then you can specify it there...
 
M

Marty

Thanks Tom :)
Marty

Tom said:
Use the sockets bind method befor you call Connect.

mySocket.Bind (New IPEndPoint (MyIPAddress, 0))
mySocket.Connect (.....)

The 0 for the port lets the network service provider assign the local
port - but if you want the local endpoint to have a specific port as
well as IP, then you can specify it there...
 

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