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 SimpleSocket mbed-rtos mbed
udpsender.cpp
00001 #include "SimpleSocket.h" 00002 00003 void udpsender() { 00004 DatagramSocket datagram; 00005 00006 char message[80] = {}; 00007 printf("Enter message => "); 00008 int c = 0; 00009 while (c < ' ' || 0x7E < c) 00010 c = getc(stdin); 00011 ungetc(c, stdin); 00012 for (int i = 0; i < sizeof(message) - 1 && (c = getc(stdin)) >= ' '; i++) 00013 message[i] = c; 00014 00015 int i1, i2, i3, i4; 00016 printf("UDP receiver address => "); 00017 scanf("%d.%d.%d.%d", &i1, &i2, &i3, &i4); 00018 00019 for (int i = 0;; i++) { 00020 printf("Sending message : %s (%d)\n", message, i); 00021 datagram.printf("(%d) %s\n", i, message); 00022 char ip[16] = {}; 00023 sprintf(ip, "%d.%d.%d.%d", i1, i2, i3, i4); 00024 datagram.send(ip, 7777); 00025 wait(1); 00026 } 00027 }
Generated on Mon Jul 18 2022 00:17:10 by
1.7.2