Advertisement

Cross-platform sockets?

Started by January 26, 2004 10:58 AM
3 comments, last by gandolf1212 21 years ago
I''m just getting back into C++ and am not very experianced with sockets. I am wondering, if I write a server program in windows using winsock, if it can be easily compiled under linux. "Beej''s Guide to Network Programming"*, seems to make it look as easy as swaping a few headers? Anyone have any experiance with this? My goal is to write a program that lets me send data between apps written in PHP, Flash, Pascal and C++ but all I have ever gotten to work is C++ and Flash, and even then it was just tic-tac-toe. *http://www.ecst.csuchico.edu/~beej/guide/net/html/intro.html
I think there's to much blood in my caffeine system.
It''s all good if you stick to Berkley sockets.

socket(...), select(...), sendto(...), recvfrom(...)...etc.

The WSAxxxx(...) functions are Windows-specific, so avoid
them if you want cross-platform.

See MSDN.



Kami no Itte ga ore ni zettai naru!
神はサイコロを振らない!
Advertisement
There are no decent cross-platform networking libraries for C++. No, using BSD sockets doesn''t count as "decent" by any meaning of the word. I was about to make a wrapper around libgnetwork when I abandoned C++ for Haskell, but I am not sure about even the portability of libgnetwork. In any case, currently, the only solution is to build an abstraction over BSD sockets yourself, such that the implementation can be freely substituted should the need for portability arise.
SDL_net is a descent Cross-Plattform Networking libary

works on linux, windows and many other platforms.


Lazzar

[edited by - Lazzar on January 27, 2004 12:11:29 PM]
---------------------------------------------------------if god gave us the source code, we could change the world!
Straight Berkely sockets works fine for me on Win32 and a couple variations of Unix/Linux with only minor differences in syntax that are trivially #defined away.
-Mike

This topic is closed to new replies.

Advertisement