Network

Does cocos2d-x have multiplatform network support?
I can not find anything about that.

You can use bsd socket, or you can use libcurl, which is offered by engine.

Please refer to Tests/tests/CurlTest/CurlTest.cpp

bsd is your best choice :stuck_out_tongue:

reference here
[[http://developer.apple.com/library/ios/#documentation/System/Conceptual/ManPages_iPhoneOS/man2/socket.2.html]](from apple)
[[http://fanqiang.chinaunix.net/a4/b8/20010811/0905001105_b.html]](chinese only)

I used http://pocoproject.org/ It has a network module.

By the way, can two Android-tablets connect with each other via TCP/IP and send and receive data instantly? I mean… can we make multiplayer games using sockets? :slight_smile:

I’m using enet (http://enet.bespin.org). Confirmed working on Windows, Android, and iOS. On Windows you need to find every single <windows.h> include and put a <winsock2.h> include before it.

Kevin H wrote:

I’m using enet (http://enet.bespin.org). Confirmed working on Windows, Android, and iOS. On Windows you need to find every single <windows.h> include and put a <winsock2.h> include before it.

I suppose it should work on MacOS too? I need this cause I develop under MacOS :slight_smile: I’ve read on the website of ENet:
“ENet works on Windows and any other Unix or Unix-like platform providing a BSD sockets interface.”
I think it should work on Linux and MacOS too, right?

do you guys know if libcurl supports sockets, or should we use another third party library for that?

BR,

JB

I have used ENet and it runs like a charm on Mac, windows and iOS. Very powerful UDP lib that offers some tcp/ip features. The only downside is that you must use portforward if you are behind a router/firewall.

1 Like