Thread: socket freezing....

  1. #1
    Registered User
    Join Date
    Apr 2010

    socket freezing....

    I am working on this program that utilizes sockets.
    So far, I have created all I need but I am running into this problem when performing the following steps:

    I have a client and a host, and the client has to remain connected to the host.
    The user can change the client's IP address so the client needs to inform the host about it's new IP.

    So far, I have been able to send in the new IP to the client... but the problem I am seeing is the client freezes for roughly 10 minutes before it establishes a new connection.

    1. Connection established (client, host
    2. Host IP is updated to
    3. host prior to completing the IP change issues a packet/command to host with new IP.
    4. Client acks the receipt of the new ip, and closes the connection (socket).
    5. Client updates the socket information with the new IP
    6. Client connects to host (and it seems to connect without any errors)
    7. Client sends an initial handshake statement and it freezes for around 10 minutes
    8. Then, it automatically receives the intial handshake ACK and from this point on, it works fine.

    I can ping the host just fine....

    Does anyone know why this happens?
    Do I need to do any type of cleanup in addition to closing the socket and reinitializing it?

    Thanks in advance.
    Last edited by v333k; 05-10-2010 at 03:56 PM. Reason: reversed host and client in my initial post

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Shouldn't you have a number in there some place like:

    4.1. Host receives ack, and closes connection and goes back to listening.

    Something along those lines?

    Hope is the first step on the road to disappointment.

  3. #3
    Registered User
    Join Date
    Apr 2010
    oh you are good.....

    I just fixed it (and that was indeed the missing step) but it is amazing that you didn't see my code to really assume that this step wasn't happening....

    appreciate your reply.....

    my hat off to you!!!!

  4. #4
    Registered User jeffcobb's Avatar
    Join Date
    Dec 2009
    Henderson, NV
    The ugly twin sister of this problem is not setting the flag to re-use the address on the server and so once a socket closes, it goes into a time-wait state for ten mins before it can be reused. PITA but it happens.
    C/C++ Environment: GNU CC/Emacs
    Make system: CMake
    Debuggers: Valgrind/GDB

  5. #5
    Registered User
    Join Date
    Apr 2010
    thanks jeffcobb. I will keep that in mind.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Function call from another .c module
    By Ali.B in forum C Programming
    Replies: 14
    Last Post: 08-03-2009, 11:45 AM
  2. Problem with socket descriptors
    By McKracken in forum C Programming
    Replies: 1
    Last Post: 07-22-2009, 08:51 AM
  3. socket programming question, closing sockets...
    By ursula in forum Networking/Device Communication
    Replies: 2
    Last Post: 05-31-2009, 05:17 PM
  4. when to close a socket
    By Wisefool in forum Networking/Device Communication
    Replies: 5
    Last Post: 11-02-2003, 10:33 AM
  5. socket newbie, losing a few chars from server to client
    By registering in forum Linux Programming
    Replies: 2
    Last Post: 06-07-2003, 11:48 AM

Tags for this Thread