I have read prior post on the forum but I came up with few specific questions about Porting Unix Socket(hereby calling it BSD socket) to Win32 Platform :
First of all, I am a native Linux C/C++ Programmer. I program in Ubuntu with GCC.
But, I usually also port my application to Win32. For that, I use the MinGW Port of GCC. I never have troubles, as I just need to compile my apps on a Windows Box with MinGW installed and I am on a go.
I don't use a IDE but a Text editor/Command Line combo.
In Linux, we have easy access to sys/socket.h, which is BSD socket library.
So, I never had trouble to program sockets on Linux.
But now, I need to port all those to Windows.
Ofcourse, I will use MinGW.
I tried to compile my simplest of the Socket Programing App on MinGW, but got the error of not having sys/socket.h.
I checked my header files in the MinGW include directory, but seriously there was no socket.h in the /sys/ directory.
Ofcourse, I could use VC++ or some other compiler and use the Winsok API(winsock.h) instead. But I dont want to use that since it will have me do a lot of conditional compiling(to make my app, platform independent) which I don't like.
Now here are my queries:
Can I just copy paste my /sys/socket.h from my Linux Box and paste it on the /sys/ of MInGW directory of the Window Box and use it at is it.
If not, what are the possible options I have so that I could use the BSD Socket(sys/socket.h) instead of WinSockets(winsock.h) apart from using any third-party libraries and header files like Boost's or ACE
Now, I read Beej's Tutorial and it says that, had I been using Cygwin, I would not experience any problem and my code will compile as it is in the Windows Box too. But personally, I prefer MinGW because it gives me freedom to use without depending from any run-time DLL.
Also, do tell me if any of you guys have written a C++ Wrapper Class of Socket which will work on Unix as well as Windows. Although, if the above problem is solved, then I would be able to use SocketCC, which is a wrapper class for Unix.
Though, it may be noted that Winsock and BSD Socket have nearly same routines, but I would prefer to use sys/socket.h since I don't wanna go in WSA() thing.