For lecture TCP
Dependencies: WIZnetInterface WIZwiki-W7500-lecture mbed
Fork of WIZwiki-W7500-lecture by
Revision 3:90acfa2e24cb, committed 2016-02-01
- Comitter:
- bangbh
- Date:
- Mon Feb 01 01:22:53 2016 +0000
- Parent:
- 2:ba228e5b659c
- Commit message:
- For lecture_TCP
Changed in this revision
WIZwiki-W7500-lecture.lib | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r ba228e5b659c -r 90acfa2e24cb WIZwiki-W7500-lecture.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/WIZwiki-W7500-lecture.lib Mon Feb 01 01:22:53 2016 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/users/bangbh/code/WIZwiki-W7500-lecture/#ba228e5b659c
diff -r ba228e5b659c -r 90acfa2e24cb main.cpp --- a/main.cpp Mon Feb 01 00:34:33 2016 +0000 +++ b/main.cpp Mon Feb 01 01:22:53 2016 +0000 @@ -12,27 +12,25 @@ printf("IP Address is %s\r\n", eth.getIPAddress()); - UDPSocket udp_sock; TCPSocketConnection tcp_sock; tcp_sock.connect("192.168.0.244", 4545); - udp_sock.init(); - udp_sock.bind(60001); - Endpoint udp_server; - udp_server.set_address("192.168.0.244",4023); - char http_cmd[] = "GET /data/2.5/weather?q=Seoul,kr HTTP/1.0\n\n"; - tcp_sock.send_all(http_cmd, sizeof(http_cmd)-1); - udp_sock.sendTo(udp_server,http_cmd,sizeof(http_cmd)-1); + char message[] = "Hello World!\r\n"; + tcp_sock.send(message, sizeof(message)-1); char buffer[400]; int ret; - while (true) { + while (true) + { ret = tcp_sock.receive(buffer, sizeof(buffer)-1); - if (ret <= 0) break; - buffer[ret] = '\0'; - printf("Received %d chars from server: %s\n", ret, buffer); + if (ret > 0) + { + buffer[ret] = '\0'; + printf("Received %d chars from server: %s\n", ret, buffer); + } } - + tcp_sock.close(); eth.disconnect(); - + + printf("Disconnected!"); } \ No newline at end of file