Hi Everyone!
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;
Identifying Clients from one another
-
- Posts: 195
- Joined: Sat Apr 01, 2017 1:21 am
- Contact:
-
- Posts: 195
- Joined: Sat Apr 01, 2017 1:21 am
- Contact:
Re: Identifying Clients from one another
Postby AgentSmithers » Tue Jan 15, 2019 6:45 am
*Bump* I'm at a point where I'm stuck as I need to resolve this issue as I need to in order to move forward.
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
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.
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.
Who is online
Users browsing this forum: No registered users and 181 guests
Login
Newbies Start Here
Are you new to ESP8266?
Unsure what to do?
Dunno where to start?
Start right here!
Latest SDK
Documentation
Complete listing of the official ESP8266 related documentation release by ESPRESSIF!
Must read here!
- All times are UTC+08:00
- Top
- Delete all board cookies
About Us
Espressif Systems is a fabless semiconductor company providing cutting-edge low power WiFi SoCs and wireless solutions for wireless communications and Internet of Things applications. We are the manufacturer of ESP8266EX.