Thread: setsockopt issues

  1. #1
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445

    setsockopt issues

    I have a multi-process linux server application that receives a connection via accept() and forks to handle the requests on that new connection. I'm calling setsockopt(ClientSocket, SOL_SOCKET, SO_REUSEADDR....) on the new sockets, and from time to time, this will completely lock up my server and make it stop passing the connections off to the handler. the new connections are accepted, and the fork occurs, but the child process just stops on the setsockopt() line.

    my question is: do I need to set that socket option on the new connection's socket, or just on the listening socket (which I also do)?

  2. #2
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by Elkvis View Post
    my question is: do I need to set that socket option on the new connection's socket, or just on the listening socket (which I also do)?
    It does not make sense to use SO_REUSEADDR on the client sockets because they do not have bind() called on them, and are already connected.

    WRT your problem, that might even be the cause of it.
    Last edited by MK27; 06-22-2011 at 11:41 AM.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  3. #3
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    that makes sense. it seems to be working better since I commented out that section of code, so I think it's fixed, but I guess we'll see what happens.

  4. #4
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by Elkvis View Post
    it seems to be working better but I guess we'll see what happens.
    Writing network code sometimes makes me think of trying to throw tennis balls into a hopper that might be a little bit too small, from twenty yards in pitch darkness, having never once seen the area in the light, with your thumb taped to your forefinger and a mysterious wind gusting intermittently from any direction.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Having issues with my FFT
    By DavidP in forum C++ Programming
    Replies: 8
    Last Post: 04-05-2010, 01:27 PM
  2. issues
    By Logan1033 in forum C Programming
    Replies: 12
    Last Post: 08-16-2006, 01:54 PM
  3. PC issues....
    By RoD in forum Tech Board
    Replies: 10
    Last Post: 03-11-2004, 05:44 PM
  4. .EXE Issues
    By SpankyTheWalrus in forum Windows Programming
    Replies: 4
    Last Post: 03-07-2004, 12:48 PM
  5. is this the right way to setsockopt()?
    By redemption in forum C Programming
    Replies: 0
    Last Post: 09-09-2002, 05:49 AM