tcp_listen()

Name

tcp_listen() -- Make PCB listen for incoming connections

Synopsis

struct tcp_pcb *tcp_listen(struct tcp_pcb *pcb);

Description

Commands pcb to start listening for incoming connections. When an incoming connection is accepted, the function specified with the tcp_accept() function will be called. pcb must have been bound to a local port with the tcp_bind() function.

Return value

The tcp_listen() function returns a new connection identifier, and the one passed as an argument to the function will be deallocated. The reason for this behavior is that less memory is needed for a connection that is listening, so tcp_listen() will reclaim the memory needed for the original connection and allocate a new smaller memory block for the listening connection.

tcp_listen() may return NULL if no memory was available for the listening connection. If so, the memory associated with pcb will not be deallocated.

2017-02-09
Documentation license for this page: eCosPro License