Hi.
It is the first time for me working with TCP connection.
I want to connect over TCP to a console application running on my pc.
My Problem:
I could not connect. In my oppinion the configuration is correct.
#include "mbed.h"
#include "EthernetNetIf.h"
#include "TCPSocket.h"
#include "host.h"
EthernetNetIf eth(
IpAddr(10,10,33,233), //IP Address
IpAddr(255,255,252,0), //Network Mask
IpAddr(10,10,35,254), //Gateway
IpAddr(10,10,2,32) //DNS
);
DigitalOut myled(LED1);
IpAddr hostIP(10,10,33,81);
Host host(hostIP,10024, "H2O-NB-1367");
TCPSocket tcp;
Serial pc(USBTX, USBRX);
EthernetErr ethErr;
int main() {
IpAddr IP;
IpAddr HIp;
pc.baud(115200);
EthernetErr ethErr = eth.setup();
if (ethErr) {
printf("Error %d in setup.\n", ethErr);
return -1;
}
TCPSocketErr tcpBin = tcp.bind(host);
if (tcpBin) {
printf("Error %d in connect.\n", ethErr);
return -1;
}
TCPSocketErr tcpErr = tcp.connect(host);
if (tcpErr) {
printf("Error %d in connect.\n", ethErr);
return -1;
}
IP = eth.getIp();
HIp = host.getIp();
pc.printf("Die aktuelle IpAdresse von mBED ist %d.%d.%d.%d\n", IP[0],IP[1],IP[2],IP[3]);
pc.printf("Die aktuelle IP von Host ist %d.%d.%d.%d\n",HIp[0],HIp[1],HIp[2],HIp[3]);
pc.printf("Der aktuelle Port von Host ist %d\n", host.getPort());
pc.printf("Der aktuelle Name von Host ist %s\n", host.getName());
while (1) {
myled = 1;
tcp.send("test\n",5);
wait(0.2);
myled = 0;
wait(0.2);
}
}
Hi.
It is the first time for me working with TCP connection. I want to connect over TCP to a console application running on my pc.
My Problem: I could not connect. In my oppinion the configuration is correct.