• Some users have recently had their accounts hijacked. It seems that the now defunct EVGA forums might have compromised your password there and seems many are using the same PW here. We would suggest you UPDATE YOUR PASSWORD and TURN ON 2FA for your account here to further secure it. None of the compromised accounts had 2FA turned on.
    Once you have enabled 2FA, your account will be updated soon to show a badge, letting other members know that you use 2FA to protect your account. This should be beneficial for everyone that uses FSFT.

socket class compatibilities windows/linux

bigoh5

n00b
Joined
Mar 19, 2009
Messages
12
I have a project built in linux that I am trying to port over to a windows vista machine. The socket libraries from unix <sys/socket.h>, <netinet/in.h>, <arpa/inet.h> obviously don't compile in a windows environment. I tried to use Services for Unix but it said my machine wasn't supported (but through my research I found that Vista Enterprise is supported).

My question is this, is winsocket close enough to these libraries to provide a quick fix that will allow it to compile (I would like for it to compile in VS2008)? Also, what would be the best way to write a layer to determine the OS of the system and to compile with different libraries based on the OS? Is there a way to do this in a makefile? $OSTYPE is a bash command, so I don't think thats an option, is it?

Thanks
 
Sort of, in windows a "Socket" is a handle, where on linux/unix platforms it is an int. Additionally on windows to start using winsock you have to call WSAStartup and to shutdown WSACleanup().

There are socket classes out there that will do this for you but the sloppy/lazy way I fist did this was littered my code with #ifdef's and typdefed Socket based on the OS...
 
Java Sockets would be corss platform for you. :)

Check out this for the makefile help:
http://stackoverflow.com/questions/714100/os-detecting-makefile

Simplest and quickest seems like to set an environment variable.

Off the top of my head, I think you could write one interface to use to communicate to the sockets, and implement that interface on each OS you like, the compile accordingly based on that environment variable. I havnt written a makefile in sometime or I'd try to write an example for ya.
 
Back
Top