Is there anyone has used Bsd Socket or any other tools for socket in cocos2d-x?

Is there anyone has used Bsd Socket or any other tools for socket in cocos2d-x?
0.0 0


I want to develope a net game which uses C/S frame,so I need to use socket connect.

At first I use cocos2d-x to make the game in win32 ,then I’ll transplant the game to iOS and Android .

Walzer has told me that I can use Bsd Socket,but I don’t know how to use Bsd Socket in win32 and how to compile Bsd Socket in iOS and Android.:frowning:

If anyone know the answer or any useful informations(websites,documents,codes…), please tell me ,thank you very very much. :smiley:


I just found some bsd socket codes for Linux like this ….(<sys/socket.h>…),
but I can’t use them in win32,.
someone told me that I can use (#include <winsock2.h> #pragma comment(lib, “ws2_32.lib”) ) instead in win32,
if I use <winsock2.h> and so on , can I transplant these code to iOS and Android???:slight_smile:


U should use odsocket,it can use for all the platform


Apple has some documentation on this:

I haven’t done any Win32 socket development in a long time, bit IIRC you might want to look at WinSock

There are some cross-platform socket libraries around. I’m not sure if I would use one. I sort of subscribe to doing the platform native way when you get this low-level, but check out:


Compiling and creating a Socket Communication Layer for a game is one of the hardest job. With a few experience in network communication for Game/Application I have some suggestion for you. With some following steps:
1 . Write a basic connection socket. (I am using Google Protocol Buffer). Compile it for iOS, Android, WP successful.
2. Write a message handler for that connection, preprocess, save data to a data-store in phone, send message back, etc.
3. Write a NetworkManager Layer which will work with some Message Handler, Read data form Data-Store, etc.
4. Improve them for your game.