I'm trying to write a program that uses sockets to connect with other instances of itself over the network. Since eventually I'd like to write a Windows version as well, I'm currently using BSD sockets on the OS X side so that I can ensure that it will be compatible with the (eventual) Windows version.
The only way that I've been able to get this to work so far is if I specify my actual IP address when creating the server socket. If I use 127.0.0.1 instead, then I can only connect from my local machine.
While this is fine in theory, the question them becomes how do I know which IP address to use? I'm not sure how to get an IP address for the current machine via Cocoa, and even if I can, what if there are multiple valid IP address (such as both an Airport and ethernet connections, for example). How do I know which one to use? I could ask the user, but that doesn't seem like something they could/should know.
I can provide my client and server connection code if necessary, however given that I am able to make a connection from a remote machine, I'm thinking that the problem isn't in my code.
Thank you for your time. :)