C Board  

Go Back   C Board > General Programming Boards > Networking/Device Communication

Reply
 
LinkBack Thread Tools Display Modes
Old 10-07-2008, 05:00 AM   #1
critical genius
 
MK27's Avatar
 
Join Date: Jul 2008
Location: SE Queens
Posts: 5,172
meaning of listen queue

Is the second argument to listen to limit the number of connect requests pending, or the total number of connections? I presume the former, since it certianly does not restrict the later with a LOCAL socket. Why/how could a program ever end up with such a queue, since a socket set to listen seems to "accept" a connection as the request is recieved?

Does this also mean that to truly limit the number of connections, a routine must exist to close them as soon as they are made beyond a certian number, or close the listening socket?
__________________

"A man can't just sit around." -- Larry Walters
MK27 is offline   Reply With Quote
Old 10-07-2008, 12:51 PM   #2
Registered User
 
Join Date: Oct 2001
Posts: 2,110
Imagine multiple clients trying to connect to a server at once. If the requests come in faster than the server can accept() them, then the listen queue fills. Up. When you accept() a connection from a socket that is listening, it removes the entry for that connection from the queue.
robwhit is offline   Reply With Quote
Old 10-08-2008, 06:33 AM   #3
critical genius
 
MK27's Avatar
 
Join Date: Jul 2008
Location: SE Queens
Posts: 5,172
Quote:
Originally Posted by robwhit View Post
If the requests come in faster than the server can accept() them, then the listen queue fills.
Just wanted to clarify for myself that this is the purpose of accept() and not to perform some possible filtering action (if (incoming==okay) accept), and that the queue is NOT the "maximum number of connections".

I'm guessing this is one way a server gets "flooded" -- the CPU clocks out handling the queue. On second thought, even if the queue is full I imagine it won't take much to just "deny" (is that an action, or a socket status detectable by connect?) and accept one by one.
__________________

"A man can't just sit around." -- Larry Walters

Last edited by MK27; 10-08-2008 at 06:38 AM.
MK27 is offline   Reply With Quote
Old 10-08-2008, 01:20 PM   #4
Registered User
 
Join Date: Oct 2001
Posts: 2,110
> Just wanted to clarify for myself that this is the purpose of accept()

accept accepts a socket from a listen queue from a listening socket.

> and not to perform some possible filtering action (if (incoming==okay) accept),

I don't know how you could direct accept to filter connections.

> and that the queue is NOT the "maximum number of connections".

I am almost completely sure that the listen queue is not the maximum number of connections, and you typically set it to some low number.

> I'm guessing this is one way a server gets "flooded" -- the CPU clocks out handling the queue. On second thought, even if the queue is full I imagine it won't take much to just "deny" (is that an action, or a socket status detectable by connect?) and accept one by one.

Yes, that's one way. Some stacks don't even refuse the connection, they just drop it.
robwhit is offline   Reply With Quote
Reply

Tags
sockets

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with FIFO QUEUE jackfraust C++ Programming 23 04-03-2009 08:17 AM
Fixing my program Mcwaffle C Programming 5 11-05-2008 03:55 AM
help with queues Unregistered C Programming 3 05-21-2002 09:09 PM
help with queues Unregistered C Programming 3 05-21-2002 11:39 AM
queue help Unregistered C Programming 2 10-29-2001 09:38 AM


All times are GMT -6. The time now is 03:08 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22