I am trying to connect from my iPhone to a socket server running on the same network on my computer. How can I get the local IP address of the computer that is running the s
Your server needs to broadcast itself using the mDNS protocol.
Then on the iPhone, you can simply use gethostbyname to get the IP address. You also have a specific API for that: DNS Service Discovery C Reference.
gethostbyname