TCP Server that handles multiple client requests at the same time using multiple threads
Dependencies: EthernetInterface Server mbed-rtos mbed Threads
Diff: main.cpp
- Revision:
- 3:91fa989f29e2
- Parent:
- 2:fe6ad47cd3eb
- Child:
- 4:b8145a198e58
--- a/main.cpp Tue Jun 11 19:26:40 2013 +0000 +++ b/main.cpp Tue Jun 11 20:43:40 2013 +0000 @@ -1,12 +1,13 @@ #include "mbed.h" #include "EthernetInterface.h" +#include "Server.h" #define SERVER_PORT 7 #define BUFFLEN 100 char buffer[256]; -void Handle_client(void const *socket_data) { +/*void Handle_client(void const *socket_data) { int socket; socket = (int)socket_data; @@ -20,12 +21,21 @@ } +}*/ + +void Start_server(void const *port) { + int _port=(int) port; + Server my_server(_port,3); + my_server.Start(); } -osThreadDef(Handle_client, osPriorityNormal, DEFAULT_STACK_SIZE); +//osThreadDef(Handle_client, osPriorityNormal, DEFAULT_STACK_SIZE); +osThreadDef(Start_server, osPriorityNormal, DEFAULT_STACK_SIZE); int main (void) { - + int port=7; + osThreadCreate(osThread(Start_server), (void *) port); + /* EthernetInterface eth; eth.init(); //Use DHCP eth.connect(); @@ -66,6 +76,6 @@ osThreadCreate(osThread(Handle_client), (void *) new_socket); - } + }*/ } \ No newline at end of file