views:

371

answers:

1

I've a server with several IP Addresses assigned to the network adapter.

On that server is a client app to connect to another server app via TCPClient. For all outgoing communications my servers default IP address is being used, however for this one application I'd like the outgoing communication to be send out on another local IP address.

Is it possible when communicating out to specify another locally assigned IP?

I'm trying to make the remote server app think it's from another IP so it will pass through firewalls etc....

Thanks in advance

+3  A: 

You can use the constructor of TcpClient that accepts a local endpoint address:

TcpClient c=new TcpClient(new System.Net.IPEndPoint(...));

For example:

TcpClient c=new TcpClient(new IPEndPoint(IPAddress.Parse("192.168.1.1"), 0);

Reference: TcpClient Constructor (IPEndPoint)

Aviad P.
Thanks for that, I wrongly assumed the constructor was the endpoint for the remote host.Out of interest is there a similar thing for the System.Net.Sockets.Socket class? It has a LocalEndPoint Property but it's only a getter and not a setter.
DaveHogan
It's OK - I found the Bind method as explained here: http://stackoverflow.com/questions/1508804/setting-a-sockets-local-endpointMany Thanks for your help Aviad
DaveHogan