receive the data from the source and * turn the data back
Dependencies: EthernetInterface mbed-rtos mbed
Fork of BroadcastReceive by
Revision 3:689f37688374, committed 2014-10-30
- Comitter:
- shiyilei
- Date:
- Thu Oct 30 17:10:08 2014 +0000
- Parent:
- 2:d4f436c47a42
- Commit message:
- receive the data from the source and; * turn the data back
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r d4f436c47a42 -r 689f37688374 main.cpp --- a/main.cpp Wed May 14 15:39:06 2014 +0000 +++ b/main.cpp Thu Oct 30 17:10:08 2014 +0000 @@ -1,8 +1,16 @@ +/*************************************************** +*file:broadcast receive +*Creator:JacobShi +*Time:2014/10/30 +*Description:receive the data from the source and +* turn the data back + *******************************************************/ + #include "mbed.h" #include "EthernetInterface.h" - -const int BROADCAST_PORT = 58083; - + +const int BROADCAST_PORT = 8080; + int main() { EthernetInterface eth; eth.init(); //Use DHCP @@ -15,9 +23,9 @@ Endpoint broadcaster; char buffer[256]; while (true) { - printf("\nWait for packet...\n"); int n = socket.receiveFrom(broadcaster, buffer, sizeof(buffer)); buffer[n] = '\0'; - printf("Packet from \"%s\": %s\n", broadcaster.get_address(), buffer); + socket.sendTo(broadcaster,buffer,sizeof(buffer)); + } -} +} \ No newline at end of file