Few clients

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view

Few clients

it is possible to listen on one port all the time and have few clients connected to tcp echo?

 in example:

static void
tcpecho_thread(void *arg)

  struct netconn *conn, *newconn;
  err_t err;

  /* Create a new connection identifier. */
  conn = netconn_new(NETCONN_TCP);

  /* Bind connection to well known port number 7. */
  netconn_bind(conn, NULL, 7);

  /* Tell connection to go into listening mode. */

  while(1) {

    /* Grab new connection. */
    newconn = netconn_accept(conn);
    /* Process the new connection. */
    if(newconn != NULL) {
      struct netbuf *buf;
      void *data;
      u16_t len;
      while((buf = netconn_recv(newconn)) != NULL) {
        do {
          netbuf_data(buf, &data, &len);
          err = netconn_write(newconn, data, len, NETCONN_COPY);
          if(err != ERR_OK) {
        } while(netbuf_next(buf) >= 0);
      /* Close connection and discard connection identifier. */

but i want  to serve more than one client how to do it?
Reply | Threaded
Open this post in threaded view

Re: Few clients

Ok i have idea how to do this....but i have one more question it is possible to check that lwIP is inited? now i do some delays but i want run aplication just after when lwIP is work OK.