Thread: help with listen and sockets.

  1. #1
    Registered User
    Join Date
    Oct 2008
    Posts
    35

    help with listen and sockets.

    server: i make a listen with 5 backlog

    and then a newfd= accept...

    several clients can connect several times, trade messages and shutdown (after closing newfd)

    the problem is that if the same client stays alive and makes more then 5 connect close cyles i get a error on the 6th connect

    does the 5 in listen mean i can only connect 5 times with each client?

    i have a printf in the server so that each time a newfd is created i get itīs number. when itīs closed by the client, i close it also in the server. close does not return -1, and the number of the closed fd is the same as newfd.

    i imagine this can be hard to understand without code, but itīs a big program...

    any help?

  2. #2
    Registered User
    Join Date
    Nov 2004
    Location
    USA
    Posts
    516
    The 5 in listen is the Backlog. You get a socket to communicate only when you accept a connection. You may get multiple connection requests. Listen queues these requests and keeps only Backlog number of requests active. If it has Backlog number of requests pending and it gets another request to connect, that request is dropped.
    Code:
    >+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++.[-]>++++++++[<++++>-] <.>+++++++++++[<++++++++>-]<-.--------.+++.------.--------.[-]>++++++++[<++++>- ]<+.[-]++++++++++.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Simple Client - Server problems (Async Sockets )
    By Cpp_Noob in forum Networking/Device Communication
    Replies: 4
    Last Post: 06-19-2009, 07:12 AM
  2. File transfer over sockets
    By adrians in forum C Programming
    Replies: 3
    Last Post: 03-02-2009, 12:56 AM
  3. Help with multithreaded sockets program
    By ceclauson in forum C Programming
    Replies: 3
    Last Post: 12-13-2008, 04:15 PM
  4. sockets( ) programming
    By xlordt in forum Networking/Device Communication
    Replies: 7
    Last Post: 09-23-2003, 09:26 PM
  5. Understanding Sockets
    By minesweeper in forum Windows Programming
    Replies: 3
    Last Post: 02-06-2003, 06:50 PM