8 years, 5 months ago.

Nucleo F207ZG Ethernet simple test

I am a beginner in mbed development. I want to transfer data from the Nucleo F207ZG to the server. (by connecting the router to the board's Ethernet port) (PC telnet testing is good.) The code below does not cause an error, but it does not connect to the server. I would appreciate your advice.

---------------

  1. if !FEATURE_LWIP
  2. error [NOT_SUPPORTED] LWIP not supported for this target
  3. endif
  1. include "mbed.h"
  2. include "EthernetInterface.h"
  3. include "TCPServer.h"
  4. include "TCPSocket.h"

const char* SERVER_ADDRESS = "115.115.115.115"; const int SERVER_PORT = 3000;

int main() { printf("Basic example\n\n");

EthernetInterface eth; eth.connect(); printf("The target IP address is '%s'\n\n", SERVER_ADDRESS);

TCPServer srv; TCPSocket sock;

srv.open(&eth); srv.bind(SERVER_ADDRESS, SERVER_PORT);

if(srv.bind(SERVER_ADDRESS, SERVER_PORT)< 0) { printf("TCP server bind failed.\n\r"); return -1; } else { printf("TCP server bind successed.\n\r"); }

char hello[] = "Hello World"; printf("Sending message to Server : '%s' \n",hello); sock.send(hello, sizeof(hello) - 1); }

Be the first to answer this question.