TCP Server that handles multiple client requests at the same time using multiple threads
Dependencies: EthernetInterface Server mbed-rtos mbed Threads
Revision 3:91fa989f29e2, committed 2013-06-11
- Comitter:
- lemniskata
- Date:
- Tue Jun 11 20:43:40 2013 +0000
- Parent:
- 2:fe6ad47cd3eb
- Child:
- 4:b8145a198e58
- Commit message:
- Server library included. Not tested
Changed in this revision
| Server.lib | Show annotated file Show diff for this revision Revisions of this file |
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Server.lib Tue Jun 11 20:43:40 2013 +0000 @@ -0,0 +1,1 @@ +Server#a5fdd089d5c6
--- 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