Listen

From Spectrum
Jump to navigation Jump to search

listen (HLCALL 0x3E06) - listens for connections on a socket.

Synopsis

Assembly language

ld a, (socket_fd)     ; Get socket handle
ld hl, LISTEN
call HLCALL

C

#include <sys/socket.h>

int listen(int sockfd, int backlog);

Description

To accept connections, a socket is first created with socket, a willingness to accept incoming connections and a queue limit for incoming connections are specified with listen(), and then the connections are accepted with accept. The listen() call applies only to sockets of type SOCK_STREAM.

The backlog parameter defines the maximum length the queue of pending connections may grow to. It is currently not implemented due to tcp offload engine limitations.

Return values

The C library function returns 0 on success, and -1 on error. The assembly language call returns with the carry flag unset on success, and carry set on error. On error, A is set to the error code.

Bugs

The C library backlog parameter is not implemented due to hardware constraints.