Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
10 years ago.
multiple clients for http server
Hi all, I have made a web server, which is running fine. It is offering a web page which takes some input from the user. Issue is I cant access this webserver from more than one computer/browser. If I tried to access it from multiple browsers. it doesnt open. It is working just for one client, can any one give me the way that i can do it for multiple clients. Below is the chunk of my code:
void serverMain(int port, char * ipage, cgi_handler * handleList, dyn_html_handler * dhList) { static TCPSocketServer server; static TCPSocketConnection client; indexPage = ipage; chList = handleList; htmlList = dhList; port_global=port; server.bind(port); printf("Main HTTP server\r\n"); // Start Listening if(server.listen() != 0); // Handle Clients and Data while(1) { printf("Main server\r\n"); status = server.accept(client); if (status >= 0) { LED_D2_ON; // Connection Accepted, Send Data // Wait for a data update client.set_blocking(true); //rest of the code
1 Answer
10 years ago.
I guess it's because you are using a single TCPSocketConnection for all clients. You need to use a different instance of TCPSocketConnection for each client.
You should also check the limits of how many TCP connections this library can handle and do some kind of management, for example if you've reached the limit, you could close the most idle connection and use that one for the new client.