Thread: More than one IP..

  1. #1
    Its not rocket science vasanth's Avatar
    Join Date
    Jan 2002
    Posts
    1,683

    More than one IP..

    Say i have a system with more than one IP.. multiple ethernet card, dial up etc etc.. Now how do I make a POSIX socket connect through a particular IP...

    thanx for any answer...

  2. #2
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    I suspect that you bind() to the appropriate IP address before calling connect(). Use a port number of zero to specify that the provider should provide the port number.

    If you just need to get the source ip address that has been used with an unbound socket you can call getsocketname() after the connect() call.

  3. #3
    * Death to Visual Basic * Devil Panther's Avatar
    Join Date
    Aug 2001
    Posts
    768
    Yeah but if you have a client program, and you didn't use bind(), it still works with multiple interfaces!

    That's because when you don't bind to an interface, the OS is the one to make the decision, using your computer's routing table.

    Infact i don't think you should ever attempt to bind the program to any interface, allow the OS to make the best decision.

    Remember that you don't really need bind() when you're writing a client, and when you're writing a server i suggest you use INADDR_ANY as your local address.
    Last edited by Devil Panther; 08-22-2004 at 01:31 PM.
    "I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe

    http://www.Bloodware.net - Developing free software for the community.

  4. #4
    Its not rocket science vasanth's Avatar
    Join Date
    Jan 2002
    Posts
    1,683
    I agree but the problem is that I will be having arounf 200 instance of the client running on a machine.. so i thought it was better to load balance between the 2 nw interface I have... will the OS automatically balance it on the two cards if it sees that both of them have access to the server???

  5. #5
    * Death to Visual Basic * Devil Panther's Avatar
    Join Date
    Aug 2001
    Posts
    768
    load sharing?

    your computer has more than one interface, and they both go the same network? are you sure about that?

    well... i guess you can connect both interfaces of the same computer to the same switch, but you'll need to define lag on that switch (by that the switch is the one to load balance the incomming data to your computer).
    but i know not all switches support this option, especially not the small 8 port type; but the bigger ones that support vlans and other advance settings. So check the load sharing thing, because i'm not sure about it.



    if it's not load sharing and you have more than one interface, this means that each interface should be connected to a different network (not the same broadcast domain - each of the interfaces has it's own default gateway).

    here the computer makes the decision according to it's routing table to find the right path to the requested host.

    but you must understand something: your computer is not a router (unless you set it up to be one) so it doesn't really know the right path, so you might have problems with it more than one interface, when your computer makes the wrong decision, because there is no way for it to know the best router, simple because it's not a router!
    Last edited by Devil Panther; 08-24-2004 at 10:34 AM.
    "I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe

    http://www.Bloodware.net - Developing free software for the community.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Converting 32 bit binary IP to decimal IP (vice-versa)
    By Mankthetank19 in forum C Programming
    Replies: 15
    Last Post: 12-28-2009, 07:17 PM
  2. IP address network order to string?
    By pobri19 in forum Networking/Device Communication
    Replies: 1
    Last Post: 04-19-2009, 05:15 AM
  3. Replies: 6
    Last Post: 06-08-2006, 04:11 PM
  4. Ip adresses
    By Da-Nuka in forum Networking/Device Communication
    Replies: 8
    Last Post: 02-27-2005, 02:25 PM