Problem with simple TCPSocketConnection

26 Dec 2014

I was just trying a simple mbed example called TCPSocket_HelloWorld. I changed the line that says connect to "mbed.org" on port 80 and made it this way so it connects to a socket opened inside of my PC. I established necessary connections between my board and the computer. Program is as below:

TCPSocket_HelloWorld

#include "mbed.h"
#include "EthernetInterface.h"

const char* IP_ADD = "192.168.2.100";
const char* MASK = "255.255.255.0";
const char* GATEWAY = "192.168.2.1";
const char* HOST_ADD = "192.168.2.200";
DigitalOut led0(P2_0);
DigitalOut led1(P2_1);
DigitalOut led2(P2_2);

int main() {
    EthernetInterface eth;
	if (eth.init(IP_ADD, MASK, GATEWAY) == 0) led0 = 1;
          else led0 = 0;	
	if (eth.connect() == 0) led1 = 1;
          else led1 = 0;
    printf("IP Address is %s\n", eth.getIPAddress());

    TCPSocketConnection sock;
    sock.connect(HOST_ADD, 41200);
        if (sock.is_connected()) led2 = 1; 
          else led2 = 0;
    char http_cmd[] = "Hello There\n\n";
    sock.send_all(http_cmd, sizeof(http_cmd)-1);
    sock.close();
    eth.disconnect();    
}

As you can see I'm not using DHCP. LED0 and LED1 are in ON state and that means Ethernet connection is on. But LED2 which shows the status of the TCPSocketConnection is off and I can't send data to my PC.

By the way I have hercules program in TCP Server mode listening on 41200 port.

So what's wrong?

27 Dec 2014

in the last couple of weeks the mbed & rtos libraries have been updated, The consequence is that my webserver using the ethernetinterface library no longer works! As i have no way of knowing who has changed what it is difficult to track down the issue.

Sorry I can only commiserate with you!