Sponsored Content
Top Forums Programming Handle int listen(int sockfd, int backlog) in TCP Post 302481989 by Corona688 on Monday 20th of December 2010 10:31:28 AM
Old 12-20-2010
Quote:
Originally Posted by sehang
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?
No, it means that no more than 128 pending connections can be waiting at once. 128 people somewhere on the internet that are doing connect(my_fd, your_server); and the server has told them "OK, wait in line".
Quote:
Can you problem me a direction that how client knows the server has been reach the limit of backlog?
I think the client will just get "connection refused" when the server already has the maximum number of pending connections waiting. Note that this is pending connections: It won't limit established connections for you, you have to do that yourself.
 

10 More Discussions You Might Find Interesting

1. Programming

Unsigned int

How can I store and/or print() a number that is larger than 4 294 967 295 in C? is int64_t or u_int64_t what I need ? if, so how can I printf it to stdout? (2 Replies)
Discussion started by: nimnod
2 Replies

2. UNIX for Dummies Questions & Answers

int.lst forms

I am working on a re-engineering project. Original Code is written in C. In the C code some "forms" are being called. Each form is in a separate file and files are tagged "int" or "int.lst" like f00.int, f00.int.lst Can some body through some light on what are these files and what is the... (2 Replies)
Discussion started by: cxredd4
2 Replies

3. Programming

difference between int ** func() and int *& func()

What is the difference between int** func() and int*& func(). Can you please explain it with suitable example. Thanks, Devesh. (1 Reply)
Discussion started by: devesh
1 Replies

4. Programming

calculating size of int

Hi, Is there any way to calculate the size of a built in data type without using 'sizeof' operator? I also don't have the option to read it from std .h file. regards Apoorva Kumar (10 Replies)
Discussion started by: apoorvasharma80
10 Replies

5. UNIX for Dummies Questions & Answers

int open(const char *pathname, int flags, mode_t mode) doubt...

hello everybody! I want to create a file with permissions for read, write, and execute to everybody using C, so I write this code: #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> int main(){ int fileDescriptor; fileDescriptor =... (2 Replies)
Discussion started by: csnmgeek
2 Replies

6. Shell Programming and Scripting

From string to int ?

hello guys i m new to shell scripting and can't find out why this structure is not right I m guessing this happens because $LINESUM is a string . so how can i do this ? i want my script to do so many loops as the number of the lines of one custom file. #!/bin/bash echo give me path name... (5 Replies)
Discussion started by: xamxam
5 Replies

7. Programming

'int air_date' '%'?

int air_date='20100103'; //2010 - Jan - 03 /* My goal here is to subtract a day. */ int day = air_date % 100; //?????? Is this right? //Are there any functions time/date for this type of date format? :cool: (7 Replies)
Discussion started by: sepoto
7 Replies

8. Programming

IPv4 string->int

Does anyone know how to convert a IP address given as 'string' into a 'u_int32_t'? Are there any build any functions already? (1 Reply)
Discussion started by: Freaky123
1 Replies

9. Programming

Division of int by double

A simple arithmetic example: 1680 / 1.12 = 1500 My C code result is 1499, here is the code: #include <stdio.h> main(int argc, char *argv) { int t = 1680; double adj = 1.12; int ires = t / adj; double fres = t / adj; ... (8 Replies)
Discussion started by: migurus
8 Replies

10. Shell Programming and Scripting

Usage of Int with NR in awk

Hello Everyone, I am new to awk and trying my hand with the diff codes and came across the below code today. It would be great if any of the Guru's help me to understand. awk '{filename = "sample_file" int((NR-1)/34) ".DAT"; print >> filename}' sample_file.DAT 34 is the no of lines each... (7 Replies)
Discussion started by: saratha14
7 Replies
listen(3XNET)					   X/Open Networking Services Library Functions 				     listen(3XNET)

NAME
listen - listen for socket connections and limit the queue of incoming connections SYNOPSIS
cc [ flag ... ] file ... -lxnet [ library ... ] #include <sys/socket.h> int listen(int socket, int backlog); DESCRIPTION
The listen() function marks a connection-mode socket, specified by the socket argument, as accepting connections, and limits the number of outstanding connections in the socket's listen queue to the value specified by the backlog argument. If listen() is called with a backlog argument value that is less than 0, the function sets the length of the socket's listen queue to 0. The implementation may include incomplete connections in the queue subject to the queue limit. The implementation may also increase the specified queue limit internally if it includes such incomplete connections in the queue subject to this limit. Implementations may limit the length of the socket's listen queue. If backlog exceeds the implementation-dependent maximum queue length, the length of the socket's listen queue will be set to the maximum supported value. The socket in use may require the process to have appropriate privileges to use the listen() function. RETURN VALUES
Upon successful completions, listen() returns 0. Otherwise, -1 is returned and errno is set to indicate the error. ERRORS
The listen() function will fail if: EBADF The socket argument 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 The socket is already connected. ENOTSOCK The socket argument does not refer to a socket. EOPNOTSUPP The socket protocol does not support listen(). The listen() function may fail if: EACCES The calling process does not have the appropriate privileges. EINVAL The socket has been shut down. ENOBUFS Insufficient resources are available in the system to complete the call. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ |MT-Level |MT-Safe | +-----------------------------+-----------------------------+ SEE ALSO
accept(3XNET), connect(3XNET), socket(3XNET), attributes(5), standards(5) SunOS 5.11 10 Jun 2002 listen(3XNET)
All times are GMT -4. The time now is 03:40 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy