Socket programming with Cygwin

Brian Dessent
Wed Dec 3 12:30:00 GMT 2008

John Emmas wrote:

> Forgive me - but as someone who's very new to socket programming, I'm
> confused about why the program worked when I built it under Linux.  Is it
> because something would have converted "localhost" to an IP address (is this
> the lookup stuff that you referred to?) and where can I find out a bit more
> about all this?

Using the older/classic Berkeley API, the socket app calls
gethostbyname() to convert a hostname to an address.  The newer modern
API is getaddrinfo() which has a slightly different interface and is
more friendly for name lookups that could return IPv6 results.

If you google "sockets programming tutorial" or the like I'm sure you
can find some detailed guides.  Keep in mind when reading these things
that the native Windows socket API is Winsock, which is similar to the
Berkeley socket API but has significant differences.  One of the
advantages of Cygwin is that you do *not* use the Winsock API, you use
Berkeley/POSIX socket API, so don't try to use any Winsock tutorials or
example code.


Unsubscribe info:
Problem reports:

More information about the Cygwin mailing list