Skip to main content
Visitor II
September 2, 2021
Solved

Is there an example of TCP/IP netconn client?

  • September 2, 2021
  • 2 replies
  • 1770 views

ip4_addr_t remote_ip;

struct netconn *clientConn;

IP4_ADDR(&remote_ip, 192, 168, 0, 11);

clientConn = netconn_new(NETCONN_TCP);

if(clientConn != NULL)

{

conn_err = netconn_connect(clientConn, &remote_ip, 8789);

if(conn_err == ERR_OK)

{

netconn_write(clientConn, message, 22, NETCONN_NOFLAG); 

}

}

netconn_close(clientConn);

netconn_delete(clientConn);

osDelay(10);

Ping works, TCP/IP Server also works, but the Client returns ERR_ABRT from the netconnect function.

Since the netconn API Server code worked without any problems, I think there will be no problems with hardware and settings.

So I'm looking for an example to refer to.

I found examples of non-netconn APIs and examples of netconn API Server, but I don't think there are examples of netconn API Clients. (I've seen a few, but they look the same as the code above.)

    This topic has been closed for replies.
    Best answer by CHan.2

    This issue has been resolved. I tested it with a Hercules file associated with my PC, but it was a problem because I didn't set an inbound rule.

    2 replies

    CHan.2Author
    Visitor II
    September 2, 2021

    The chip I use is H743VI.

    CHan.2AuthorAnswer
    Visitor II
    September 2, 2021

    This issue has been resolved. I tested it with a Hercules file associated with my PC, but it was a problem because I didn't set an inbound rule.