test
Dependencies: C12832 EthernetInterface mbed-rtos mbed
Fork of UDPEchoClient by
Diff: main.cpp
- Revision:
- 9:42a7f24bd00c
- Parent:
- 8:ae11db01fb2d
--- a/main.cpp Tue May 05 20:08:56 2015 +0000 +++ b/main.cpp Wed Jun 17 21:12:25 2015 +0000 @@ -1,33 +1,13 @@ -#include "mbed.h" -#include "EthernetInterface.h" - -const char* ECHO_SERVER_ADDRESS = "192.168.2.2"; -const int ECHO_SERVER_PORT = 7; - -int main() { - EthernetInterface eth; - eth.init(); //Use DHCP - eth.connect(); - printf("\nClient IP Address is %s \n", eth.getIPAddress()); - - UDPSocket sock; - sock.init(); - - Endpoint echo_server; - echo_server.set_address(ECHO_SERVER_ADDRESS, ECHO_SERVER_PORT); - - char out_buffer[] = "Hello World"; - printf("Sending message '%s' to server (%s)\n",out_buffer,ECHO_SERVER_ADDRESS); - sock.sendTo(echo_server, out_buffer, sizeof(out_buffer)); - - char in_buffer[256]; - int n = sock.receiveFrom(echo_server, in_buffer, sizeof(in_buffer)); - - in_buffer[n] = '\0'; - printf("Received message from server: '%s'\n", in_buffer); - - sock.close(); - - eth.disconnect(); - while(1) {} +#include <stdlib.h> +#include "lib_socket.h" + +int main(){ + const char* ipAddress = "130.237.53.141"; + const int port = 102; + + char* out_buffer =(char *)calloc(50,sizeof(char)); + out_buffer = "Hi Albert...How are you?"; + + send_message_UDP(out_buffer, ipAddress, port); + return 0; } \ No newline at end of file