I have two machines I\'m testing my code on, one works fine, the other I\'m having some problems and I don\'t know why it is.
I\'m using an object (C++) for the netw
It seems that you are picking the interface that your server listens on by selecting the first interface that you can both create a socket for and bind to? This seems a novel way to do it...
Surely, on a machine with multiple NICs you are quite likely to want to bind to one rather than another and you're likely to KNOW which one you want; for example, if we have 2 NICs, one facing the internet and one facing an internal private network you probably know which interface you want to bind to and provide your service on and what your code appears to be doing is just selecting the first that it can both create a socket for and bind to...
Anyway, I would imagine that on the machine that you cant send from you're binding to an interface that is pointing at a network that doesn't have connectivity to your target address... Since you say you can receive data on that socket and from the code snippet I assume that you're trying to send back to the address you just received from it looks like the routing table of the machine that you're running on when you're having problems is setup incorrectly and that it can't route from itself to the target machine but the target machine CAN route to the server...
Few things to check 1. Run the server. Use netstat and see the IP and the port that the server is bound to. Is the IP a localhost IP or the 0.0.0.0 IP ? 2. Once you know that the server is listening on the right port and that the address is fine, check if you can telnet to the port. Just try this telnet 3. This will attempt a connection to the port (doesn't matter that it is not a telnet server, you can use this to check connectivity) 4. If telnet is able to connect to the port i.e. no errors, you can then check the client code to see what you are missing. And like Glen mentioned, did you check you are able to make remote connections from the client machine ?