Select client IP for connecting to a server

Everything else that doesn't fall into one of the other PB categories.
merendo
Enthusiast
Enthusiast
Posts: 449
Joined: Sat Apr 26, 2003 7:24 pm
Location: Germany
Contact:

Select client IP for connecting to a server

Post by merendo »

Hey folks,

assume a computer has multiple IP addresses which it can use to connect to a server. Is there any way I can tell OpenNetworkConnection() to use any specific IP address for establishing that connection (i.e. the ClientIP() which the server will then see)?

I have already found a solution for this problem but that didn't use native code at all; using this solution would involve rewriting large portions of my application and I'd like to avoid that if possible.

Thanks a lot!
merendo
The truth is never confined to a single number - especially scientific truth!
culita
User
User
Posts: 29
Joined: Thu May 03, 2012 1:24 pm

Re: Select client IP for connecting to a server

Post by culita »

yes TOVARISH you can!

http://www.tomshardware.co.uk/forum/399 ... onnections

and here we go TOVARISH !!!
http://www.r1ch.net/stuff/forcebindip/

combining with your knoledge about networks and purebasic client server programs you got it!
DarkPlayer
Enthusiast
Enthusiast
Posts: 107
Joined: Thu May 06, 2010 11:36 pm

Re: Select client IP for connecting to a server

Post by DarkPlayer »

If you just want to have a fast solution for your self, you can hook the connect api in your application. Instead of allowing Purebasic to call connect directly, you bind the socket to the interface and forward the request to the original api call.

I recommend to use this method only for personal use, as hooking could be intrepreted as some kind of virus or trojan (although a virus hooking it self would be ridiculous) and would fail if the command would just change a bit in the next version of the operating system.

DarkPlayer
Post Reply