Hello,
I tried to send simple Data over TCP. I tested the UDP Demo Programm and it works. http://mbed.org/users/donatien/programs/UDPSocketExample/5yuvy
So there is no Hardwareproblem.
Now I wrote an Code for TCP. But I cannot receive any Data. Can you help?
#include "mbed.h"
#include "EthernetNetIf.h"
#include "TCPSocket.h"
EthernetNetIf eth(
IpAddr(192,168,1,2), //IP Address
IpAddr(255,255,255,0), //Network Mask
IpAddr(192,168,1,1), //Gateway
IpAddr(192,168,1,1) //DNS
);
TCPSocket tcp;
int main() {
printf("Setting up...\n");
EthernetErr ethErr = eth.setup();
if(ethErr)
{
printf("Error %d in setup.\n", ethErr);
return -1;
}
printf("Setup OK\n");
Host server(IpAddr(192, 168, 1, 1), 12345);
tcp.bind(server);
Timer tmr;
tmr.start();
while(true)
{
Net::poll();
if(tmr.read() > 5)
{
tmr.reset();
const char* str = "Hello world!";
tcp.send(str, strlen(str));
printf("%s\n", str);
}
}
}
Hello,
I tried to send simple Data over TCP. I tested the UDP Demo Programm and it works. http://mbed.org/users/donatien/programs/UDPSocketExample/5yuvy
So there is no Hardwareproblem.
Now I wrote an Code for TCP. But I cannot receive any Data. Can you help?
#include "mbed.h"
#include "EthernetNetIf.h"
#include "TCPSocket.h"
EthernetNetIf eth(
IpAddr(192,168,1,2), //IP Address
IpAddr(255,255,255,0), //Network Mask
IpAddr(192,168,1,1), //Gateway
IpAddr(192,168,1,1) //DNS
);
TCPSocket tcp;
int main() {
printf("Setting up...\n");
EthernetErr ethErr = eth.setup();
if(ethErr)
{
printf("Error %d in setup.\n", ethErr);
return -1;
}
printf("Setup OK\n");
Host server(IpAddr(192, 168, 1, 1), 12345);
tcp.bind(server);
Timer tmr;
tmr.start();
while(true)
{
Net::poll();
if(tmr.read() > 5)
{
tmr.reset();
const char* str = "Hello world!";
tcp.send(str, strlen(str));
printf("%s\n", str);
}
}
}