[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] Limit tcp_listen to single connection

From: Simon Goldschmidt
Subject: Re: [lwip-users] Limit tcp_listen to single connection
Date: Wed, 10 Oct 2007 21:56:59 +0200

Why not close the listening pcb in your accept function? And then set it up again after closing the other connection (tcp_err gets called if you don't close it yourself).

Except set MEMP_NUM_TCP_PCB=1 in your lwipopts.h, I don't think there is a way to do that with tcp_listen. Even in socket layer, with "lwip_listen(int s, int backlog)", the "backlog" parameter is not used. But you can close as soon as possible any new connection: to do that, you can use a boolean initialized to false, and in "accept" callback (set by tcp_accept), you do something like this:
int connected=0;
static err_t accept_function(void *arg, struct tcp_pcb *newpcb, err_t err)
{ if (connected) {
  } else {
    /* your normal accept behavior */
and when you have finish to use your "single" connection, you reset connected to 0.

----- Original Message -----

Sent: Wednesday, October 10, 2007 8:46 PM
Subject: [lwip-users] Limit tcp_listen to single connection

Is there a way to limit the tcp_listen function to only accept a single connection.  I would like to limit a specific port to accept the first connection request and then refuse any additional connections until the first connection has been closed.  Does anyone know of a way to do this?

lwip-users mailing list
lwip-users mailing list

reply via email to

[Prev in Thread] Current Thread [Next in Thread]