ESP8266 Developer Zone The Official ESP8266 Forum 2019-01-15T06:45:09+08:00 https://bbs.espressif.com:443/feed.php?f=7&t=25488 2019-01-15T06:45:09+08:00 2019-01-15T06:45:09+08:00 https://bbs.espressif.com:443/viewtopic.php?t=25488&p=36754#p36754 <![CDATA[Re: Identifying Clients from one another]]> Thanks for any pointers!

Another example of this

https://github.com/scottjgibson/esp8266 ... /espconn.h

LOCAL void ICACHE_FLASH_ATTR WebServerConn_recv_callback(void *arg, char *pusrdata, unsigned short length)
{
bool unloadafter = false;
struct espconn * pespconn = (struct espconn *) arg;

os_printf("WebServerConn_recv_callback");
os_printf(pespconn->proto.tcp->client_port);
os_printf(pespconn->tcp.client_port); //How to identify which socket is triggering this WebServerCallback. What if multiple clients are connected?
os_printf("\r\n");
}


Error returned

main.c: In function 'WebServerConn_recv_callback':
main.c:148:31: error: 'esp_tcp' has no member named 'client_port'
os_printf(pespconn->proto.tcp->client_port);
^
main.c:149:20: error: 'struct espconn' has no member named 'tcp'
os_printf(pespconn->tcp.client_port); //How to identify which socket is triggering this WebServerCallback. What if multiple clients are connected?
^


I am really just trying to identify each unique socket that's opened and not each unique client. More of a session based socket functionality.

Statistics: Posted by AgentSmithers — Tue Jan 15, 2019 6:45 am


]]>
2019-01-14T11:06:58+08:00 2019-01-14T11:06:58+08:00 https://bbs.espressif.com:443/viewtopic.php?t=25488&p=36732#p36732 <![CDATA[Identifying Clients from one another]]> What is the best way to be able to identify a TCP client from one another? I am creating a TCP Server where clients are sending me request that is trigging the recv function. However, I want to be able to identify each client by it's TCP socket so I can take action on it when data is received.

I found this structure, I was thinking maybe if I take a look at client_port or server_port I may be able to just use those unique numbers to identify the client when data comes in?
typedef struct _esp_tcp {
int client_port;
int server_port;
char ipaddr[4];
espconn_connect_callback connect_callback;
espconn_connect_callback reconnect_callback;
espconn_connect_callback disconnect_callback;
} esp_tcp;

Statistics: Posted by AgentSmithers — Mon Jan 14, 2019 11:06 am


]]>