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: WIZnetInterface WIZwiki-W7500-lecture mbed
Fork of WIZwiki-W7500-lecture1-tcp by
main.cpp
- Committer:
- bangbh
- Date:
- 2016-02-01
- Revision:
- 4:d164f370aa56
- Parent:
- 3:90acfa2e24cb
- Child:
- 5:b0e5f03fe7b8
File content as of revision 4:d164f370aa56:
#include "mbed.h"
#include "EthernetInterface.h"
int main() {
EthernetInterface eth;
uint8_t mac_addr[6] = {0x00, 0x08, 0xDC, 0xFF, 0xFF, 0xFF};
eth.init(mac_addr, "192.168.0.180", "255.255.255.0", "192.168.0.1"); // USE Static IP
//eth.init(mac_addr); //Use DHCP
eth.connect();
printf("IP Address is %s\r\n", eth.getIPAddress());
TCPSocketConnection tcp_sock;
tcp_sock.connect("192.168.0.244", 4545);
char message[] = "Hello World!\r\n";
tcp_sock.send(message, sizeof(message)-1);
char buffer[400];
int ret;
while (true)
{
ret = tcp_sock.receive(buffer, sizeof(buffer)-1);
if (ret > 0)
{
buffer[ret] = '\0';
printf("Received %d chars from server: %s\n", ret, buffer);
}
}
tcp_sock.close();
eth.disconnect();
printf("Disconnected!");
}
