Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: clarity510 on February 08, 2016, 04:16:16 PM



Title: socket libraries for bitcoin windows/osx
Post by: clarity510 on February 08, 2016, 04:16:16 PM
Hey,

What socket libraries does bitcoin use?

I found this in netbase.cpp:
#ifndef WIN32
#if HAVE_INET_PTON
#include <arpa/inet.h>
#endif
#include <fcntl.h>
#endif

Does that mean for OS X they use arpa/inet.h and for windows it's fcntl.h?

Do those two libraries use the same functions?

Thanks,
Ryan Ragle


Title: Re: socket libraries for bitcoin windows/osx
Post by: achow101 on February 08, 2016, 09:56:23 PM
Hey,

What socket libraries does bitcoin use?

I found this in netbase.cpp:
#ifndef WIN32
#if HAVE_INET_PTON
#include <arpa/inet.h>
#endif
#include <fcntl.h>
#endif

Does that mean for OS X they use arpa/inet.h and for windows it's fcntl.h?

Do those two libraries use the same functions?

Thanks,
Ryan Ragle
This means that if WIN32 has not yet been defined, then if HAVE_INET_PTON is true, then it will include arpa/inet.h and fcntl.h, otherwise it will include just fcntl.h. These include apply to windows only because the condition surrounding the whole thing is checking for windows.

I'm assuming the two libraries are used because one is better than the other, but it doesn't exist on all systems. Later in the code you can see conditions for HAVE_INET_PTON which only compiles if that is true.