Sponsored Content
Top Forums Programming Handle int listen(int sockfd, int backlog) in TCP Post 302482195 by sehang on Monday 20th of December 2010 08:37:56 PM
Old 12-20-2010
If the problem does not related with the listen(), it may be an interesting thing.

I sent 1024 packets to the server (a PC has both sender and receiver, that means, it send packets to itself).
When I Ctrl+C to close and reopen the program few times, the receiver may receive extra package and garbage; and some packets are missing.

If I send 65535 packets at a time, this problem happens more frequency.
 

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(2)						     Linux Programmer's Manual							 LISTEN(2)

NAME
listen - listen for connections on a socket SYNOPSIS
#include <sys/types.h> /* See NOTES */ #include <sys/socket.h> int listen(int sockfd, int backlog); DESCRIPTION
listen() marks the socket referred to by sockfd as a passive socket, that is, as a socket that will be used to accept incoming connection requests using accept(2). The sockfd argument is a file descriptor that refers to a socket of type SOCK_STREAM or SOCK_SEQPACKET. The backlog argument defines the maximum length to which the queue of pending connections for sockfd may grow. If a connection request arrives when the queue is full, the client may receive an error with an indication of ECONNREFUSED or, if the underlying protocol supports retransmission, the request may be ignored so that a later reattempt at connection succeeds. RETURN VALUE
On success, zero is returned. On error, -1 is returned, and errno is set appropriately. ERRORS
EADDRINUSE Another socket is already listening on the same port. EBADF The argument sockfd is not a valid descriptor. ENOTSOCK The argument sockfd is not a socket. EOPNOTSUPP The socket is not of a type that supports the listen() operation. CONFORMING TO
4.4BSD, POSIX.1-2001. The listen() function call first appeared in 4.2BSD. NOTES
To accept connections, the following steps are performed: 1. A socket is created with socket(2). 2. The socket is bound to a local address using bind(2), so that other sockets may be connect(2)ed to it. 3. A willingness to accept incoming connections and a queue limit for incoming connections are specified with listen(). 4. Connections are accepted with accept(2). POSIX.1-2001 does not require the inclusion of <sys/types.h>, and this header file is not required on Linux. However, some historical (BSD) implementations required this header file, and portable applications are probably wise to include it. The behavior of the backlog argument on TCP sockets changed with Linux 2.2. Now it specifies the queue length for completely established sockets waiting to be accepted, instead of the number of incomplete connection requests. The maximum length of the queue for incomplete sockets can be set using /proc/sys/net/ipv4/tcp_max_syn_backlog. When syncookies are enabled there is no logical maximum length and this setting is ignored. See tcp(7) for more information. If the backlog argument is greater than the value in /proc/sys/net/core/somaxconn, then it is silently truncated to that value; the default value in this file is 128. In kernels before 2.4.25, this limit was a hard coded value, SOMAXCONN, with the value 128. EXAMPLE
See bind(2). SEE ALSO
accept(2), bind(2), connect(2), socket(2), socket(7) COLOPHON
This page is part of release 3.27 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/. Linux 2008-11-20 LISTEN(2)
All times are GMT -4. The time now is 09:03 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy