LISTEN(2) BSD System Calls Manual LISTEN(2)NAME
listen -- listen for connections on a socket
SYNOPSIS
#include <sys/socket.h>
int
listen(int socket, int backlog);
DESCRIPTION
Creation of socket-based connections requires several operations. First, a socket is created with socket(2). Next, a willingness to accept
incoming connections and a queue limit for incoming connections are specified with listen(). Finally, the connections are accepted with
accept(2). The listen() call applies only to sockets of type SOCK_STREAM or SOCK_SEQPACKET.
The backlog parameter defines the maximum length for the queue of pending connections. If a connection request arrives with the queue full,
the client may receive an error with an indication of ECONNREFUSED. Alternatively, if the underlying protocol supports retransmission, the
request may be ignored so that retries may succeed.
RETURN VALUES
The listen() function returns the value 0 if successful; otherwise the value -1 is returned and the global variable errno is set to indicate
the error.
ERRORS
Listen() will fail if:
[EACCES] The current process has insufficient privileges.
[EBADF] The argument socket is not a valid file descriptor.
[EDESTADDRREQ] The socket is not bound to a local address and the protocol does not support listening on an unbound socket.
[EINVAL] socket is already connected.
[ENOTSOCK] The argument socket does not reference a socket.
[EOPNOTSUPP] The socket is not of a type that supports the operation listen().
SEE ALSO accept(2), connect(2), socket(2)BUGS
The backlog is currently limited (silently) to 128.
HISTORY
The listen() function call appeared in 4.2BSD.
4.2 Berkeley Distribution December 11, 1993 4.2 Berkeley Distribution
Check Out this Related Man Page
LISTEN(2) BSD System Calls Manual LISTEN(2)NAME
listen -- listen for connections on a socket
SYNOPSIS
#include <sys/socket.h>
int
listen(int socket, int backlog);
DESCRIPTION
Creation of socket-based connections requires several operations. First, a socket is created with socket(2). Next, a willingness to accept
incoming connections and a queue limit for incoming connections are specified with listen(). Finally, the connections are accepted with
accept(2). The listen() call applies only to sockets of type SOCK_STREAM.
The backlog parameter defines the maximum length for the queue of pending connections. If a connection request arrives with the queue full,
the client may receive an error with an indication of ECONNREFUSED. Alternatively, if the underlying protocol supports retransmission, the
request may be ignored so that retries may succeed.
RETURN VALUES
The listen() function returns the value 0 if successful; otherwise the value -1 is returned and the global variable errno is set to indicate
the error.
ERRORS
listen() will fail if:
[EACCES] The current process has insufficient privileges.
[EBADF] The argument socket is not a valid file descriptor.
[EDESTADDRREQ] The socket is not bound to a local address and the protocol does not support listening on an unbound socket.
[EINVAL] socket is already connected.
[ENOTSOCK] The argument socket does not reference a socket.
[EOPNOTSUPP] The socket is not of a type that supports the operation listen().
SEE ALSO accept(2), connect(2), connectx(2), socket(2)BUGS
The backlog is currently limited (silently) to 128.
HISTORY
The listen() function call appeared in 4.2BSD.
4.2 Berkeley Distribution March 18, 2015 4.2 Berkeley Distribution
I am trying to write a C server code that will handle WWW request from client. i am very new to socket programming. i can very well setup the socket...but when an incomin request comes from a browser, the progrom exits with an error message "Bad address". the following is the code. please do help... (1 Reply)
I've got a program running using epoll to poll activity on a listening socket. I want to be able to output a message to the terminal when the socket is connected to from the client app. It appears that epoll doesn't throw any events on the connect but only on the socket activity. Is there any... (1 Reply)
I am not able to receive the message on socket in the current process when its waiting for its child to exit.
code looks something like below
//in one thread of the current process
//thread 1
===============================================
int numBytes = read(sockid,buf,SIZE); //Now the... (2 Replies)
hi
i want to write simple socket program which will listen on socket . here is the code
## read msg on socket
#! /usr/bin/perl
use IO::Socket::INET;
my $MySocket= IO::Socket::INET->new(LocalPort=>1234,
Proto=>'udp') ;
while ()... (2 Replies)
I have a socket and a message queue over which i am trying to multiplex input using select().
When data comes over socket the select works but when it comes over message queue the select is not detecting it .
Create_Q gets the identifier of the messege queue.
... (1 Reply)
Hello there:
What is default value of listen if I, avoid init it on constructor. I need maximum num for Listen. I want to write a daemon thus i need unlimited listen.
my $sock = IO::Socket::INET->new( Listen => 20,
LocalPort => $port,
Reuse => 1)
Thanks in advance. (3 Replies)
Hi all,
On the server side, one socket is used for listening, the others are used for communicating with the client.
My question is: if i want to set option for socket, which socket should be set on?
If either can be set, what's the different?
Again, what's the different if set option... (1 Reply)
Hi,
I am having an issue with using sockets.
I have a program which binds to a socket and listen on it. Later I spawn a thread to handle some function. In the new thread created I need to call a shell script which executes the specified function. Here I am using a system command to call the... (5 Replies)
hi,
I want to find the queue size of the listen system call which is defined as below
listen(s, backlog)
The backlog parameter sets the maximum number of outstanding connections which can be queued awaiting acceptance by the server.
I want to know where is this... (2 Replies)
Dear Experts,
i am compiling my code in suse 4.1 which is compiling fine,
but at runtime it is showing me for socket programming error no 88
as i searched in errno.h it is telling me socket operation on non socket,
what is the meaning of this , how to deal with this error , please... (1 Reply)
I'm not to sure how to go about this questions, so I will just ask it and then get criticized. How many Established connections should a V440 be able to support? (4 Replies)
Hello,
the function listen creates a list that memorizes a number of incoming calls through a socket but how do the first call is deleted and the second becomes the first, is it done using accept?
I have read that accept can wait if it finds no calls in the listen list ,is it the same with read... (7 Replies)
Hi,
from the manual
listen(2): listen for connections on socket - Linux man page
It has a parameter called backlog and it limits the maximum length of queue of pending list.
If I set backlog to 128, is it means no more than 128 packets can be handled by server?
If I have three... (3 Replies)
I need clarification on whether it is okay to set socket options on a listening socket
simultaneously when it is being used in an accept() call?
Following is the scenario:-
-- Task 1 - is executing in a loop - polling a listen socket, lets call it 'fd', (whose file descriptor is global)... (2 Replies)
Hi,
We cant set the listen address of my java process to the IP address or any of the DNS names listen in the hosts file of the server.
We can access the resources of the pid in the web browser through http://<IP / DNS>:port/console
Based on the pid, how can we find what is the listen... (6 Replies)