Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: EthernetInterface Server mbed-rtos mbed Threads
main.cpp@4:b8145a198e58, 2013-06-11 (annotated)
- Committer:
- lemniskata
- Date:
- Tue Jun 11 21:15:59 2013 +0000
- Revision:
- 4:b8145a198e58
- Parent:
- 3:91fa989f29e2
TCP Server that handles multiple client requests at the same time by using multiple threads
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
lemniskata | 0:724a1b7b59ca | 1 | #include "mbed.h" |
lemniskata | 0:724a1b7b59ca | 2 | #include "EthernetInterface.h" |
lemniskata | 3:91fa989f29e2 | 3 | #include "Server.h" |
lemniskata | 0:724a1b7b59ca | 4 | |
lemniskata | 3:91fa989f29e2 | 5 | |
lemniskata | 3:91fa989f29e2 | 6 | void Start_server(void const *port) { |
lemniskata | 3:91fa989f29e2 | 7 | int _port=(int) port; |
lemniskata | 3:91fa989f29e2 | 8 | Server my_server(_port,3); |
lemniskata | 4:b8145a198e58 | 9 | int n=my_server.Start(); |
lemniskata | 4:b8145a198e58 | 10 | if(n==-1) |
lemniskata | 4:b8145a198e58 | 11 | { |
lemniskata | 4:b8145a198e58 | 12 | //printf("Server startup failed\n"); |
lemniskata | 4:b8145a198e58 | 13 | } |
lemniskata | 0:724a1b7b59ca | 14 | } |
lemniskata | 0:724a1b7b59ca | 15 | |
lemniskata | 4:b8145a198e58 | 16 | |
lemniskata | 3:91fa989f29e2 | 17 | osThreadDef(Start_server, osPriorityNormal, DEFAULT_STACK_SIZE); |
lemniskata | 2:fe6ad47cd3eb | 18 | |
lemniskata | 0:724a1b7b59ca | 19 | int main (void) { |
lemniskata | 3:91fa989f29e2 | 20 | int port=7; |
lemniskata | 4:b8145a198e58 | 21 | osThreadCreate(osThread(Start_server), (void *) port); |
lemniskata | 4:b8145a198e58 | 22 | /* do your thing*/ |
lemniskata | 0:724a1b7b59ca | 23 | |
lemniskata | 0:724a1b7b59ca | 24 | } |