0

I'm working on a project where I'd like to transfer data over TCP/IP sockets in a C program between two computers connected over WiFi to a home router, both are running Debian-based Linix distributions. I'd like to be able to connect from the client machine with only knowledge of a hostname of the device. I don't have control over the router and so I can't set a static IP for the device.

Is there an API available for retrieving an IP address given a hostname and where could I go for more information on using that API in C?

  • 2
  • +1 for getaddrinfo() but actually this may just not be possible on a home network depending on DNS and DHCP configuration - if you're using ISP DNS servers directly then the router (which knows hostname to IP mapping) won't provide an answer. – Dave C Feb 3 at 1:06
  • it's not the best interface anyway (not asynchronous etc), but it's not either doing only dns resolution. it could do mDNS (avahi/zeroconf/bonjour ...) resolution if nsswitch.conf tells to – A.B Feb 3 at 1:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.