---
name: "socket_listen"
section: "3"
platform: "linux"
package: "libowfat-dev"
version: "0.32-5"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/socket_listen"
---

# socket\_listen(3)

attempt to make a TCP connection

## NAME

socket\_listen - attempt to make a TCP connection

## SYNTAX

**#include \<libowfat/socket.h\>**

int **socket\_listen**(int *s*,int *n*);

## DESCRIPTION

socket\_listen prepares TCP socket *s* to accept TCP connections.  It allows a backlog of approximately *n* TCP SYNs. (On systems supporting SYN cookies, the backlog is irrelevant.) Normally socket\_listen returns 0.

If anything goes wrong, socket\_listen returns -1, setting errno appropriately.

## EXAMPLE

  \#include \<libowfat/socket.h\>

  int *s*;\
   char *ip*\[16\];\
   uint16 *p*;

  if ((*s*=socket\_tcp6())==-1)\
     strerr\_die2sys(111,FATAL,"unable to create TCP socket: ");\
   if (socket\_bind6\_reuse(*s*,(char \*)V6any,8002,0) == -1)\
     strerr\_die2sys(111,FATAL,"unable to bind: ");\
   if (socket\_listen(*s*,1) == -1)\
     strerr\_die2sys(111,FATAL,"unable to listen: ");

## SEE ALSO

[socket\_connect4(3)](/socket_connect4/3.md), [socket\_connect6(3)](/socket_connect6/3.md)
