multi connections to a single tcp server

alexchang
Posts: 52
Joined: Mon Apr 06, 2015 5:47 pm

multi connections to a single tcp server

Postby alexchang » Wed Apr 22, 2015 11:40 pm

We meet a problem when we use espconn_connect api call.

We want to simulate the node.js's socket.io (websocket) under our private server, but we don't get the chance and not lucky enough to use the regular websocket transport, we still use polling transport to talk with socket.io server.
By using to tcp connection, one uses to polling data from server, one uses as post data to server, by this case, we need a fixed polling tcp connection constantly connected with server, and another tcp connection used to update the esp8266 status, which is how's the light on or off, how's the plug on or off, but right now when we raise another connection to the same server we got the error below:
#define ESPCONN_ISCONN -15 /* Already connected. */

Is there any way to work around the this limitation? Thanks!

ESP_Faye
Posts: 1646
Joined: Mon Oct 27, 2014 11:08 am

Re: multi connections to a single tcp server

Postby ESP_Faye » Thu Apr 23, 2015 10:48 am

Hi,

TCP multi connection,at least , remote port need to be different, pespconn->proto.tcp->remote_port

alexchang
Posts: 52
Joined: Mon Apr 06, 2015 5:47 pm

Re: multi connections to a single tcp server

Postby alexchang » Thu Apr 23, 2015 11:08 am

Is there way to open two connections? By using polling transport to talk with socket.io server, we need to simulate PING/PONG (keep alive) protocal then we need two open connections.

ESP_Faye
Posts: 1646
Joined: Mon Oct 27, 2014 11:08 am

Re: multi connections to a single tcp server

Postby ESP_Faye » Thu Apr 23, 2015 1:32 pm

Hi,

yes,it can. user_webserver.c in IOT_Demo is an example of TCP server.

Can you provide your test code for debugging ?

alexchang
Posts: 52
Joined: Mon Apr 06, 2015 5:47 pm

Re: multi connections to a single tcp server

Postby alexchang » Thu Apr 23, 2015 2:00 pm

>TCP multi connection,at least , remote port need to be different, pespconn->proto.tcp->remote_port

I mean multi connections under same port and same ip open at the same time.

Or can you help us import this library?
http://socket.io/blog/socket-io-cpp/

JamesBlack
Posts: 1
Joined: Mon Oct 16, 2017 7:03 pm

Re: multi connections to a single tcp server

Postby JamesBlack » Mon Oct 16, 2017 7:24 pm

Hi
I know its an old discussion, but I have the same problem.
I made it work using C-only language. When I'm trying to use C++, this exact problem happens.
I heard in some versions there was a bug related to local_port assignment.
Any chance something like this is inside C++ libraries? I'm using Non-OS SDK 2.0.0.

Thanks

Who is online

Users browsing this forum: No registered users and 307 guests