receive the data from the source and * turn the data back
Dependencies: EthernetInterface mbed-rtos mbed
Fork of BroadcastReceive by
Diff: main.cpp
- Revision:
- 3:689f37688374
- Parent:
- 0:28ba970b3e23
--- 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