Simple code for TCP

28 Apr 2016

Hi to All I want to write a very simple Code for Embed Platform (LPC 1768) And I have Problem I connect the borard (with rj45) to a switch . my laptop is connected too I write and test the following code :

  1. include "mbed.h"
  2. include "EthernetInterface.h"

DigitalOut m_led(LED2); Ethernet eth_m;

int main() {

char buf[0x600]; 1536 m_led = 1; EthernetInterface eth; eth.init(); Use DHCP eth.connect(); printf("IP Address is %s\n", eth.getIPAddress()); m_led = 0;

if (eth_m.link()) { printf("online\n"); } else { printf("offline\n"); }

while(1) { int size = eth_m.receive(); if(size > 0) { eth_m.read(buf, size); printf("Destination: %02X:%02X:%02X:%02X:%02X:%02X\n", buf[0], buf[1], buf[2], buf[3], buf[4], buf[5]); printf("Source: %02X:%02X:%02X:%02X:%02X:%02X\n", buf[6], buf[7], buf[8], buf[9], buf[10], buf[11]); }

wait(1); } }

but when I want to connect to the LPC throw Laptop (By hercules terminal whit LPC's IP and Port 23) it shows me Error 10061 !! Can you Help me ?? I want a simple test for send and Recieve with TCP protocol.