CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2003
    Posts
    82

    socket re-initialize????

    I have a Client socket obj in server socket app......
    its used for sending and receiving....
    Client.Create();

    after assigning it to a socket.
    Accept(Client,0,0)

    I can
    Client.Send(data,strlen(data));

    after disconnecting from the socket, the Client object is unable to receive any connection when i assign it with Accept(Client,0,0) again....

    Is there any re-initialisation that needs to b done?

  2. #2
    Join Date
    May 2000
    Location
    KY, USA
    Posts
    18,652
    Well...Clients do not use 'Accept()'? The server socket will accept incoming connections but not the client....thus, I do not understand the question here...

  3. #3
    Join Date
    Sep 2003
    Posts
    82
    serversocket.create()
    serversocket.listen()
    OnAccept()
    {
    serversocket.Accept(Clientsocket,0,0)
    //when accepting, I assign it to the Client socket object.....
    //this is the client object i mean.....
    //It is a client socket object in a socket server application
    }

  4. #4
    Join Date
    May 2000
    Location
    KY, USA
    Posts
    18,652
    Okay...it looks like you are using the same client socket over and over again. Thus, it will fail. Of a socket connection is closed, the socket will basically fall into a TIME_WAIT state. This state (between 30 seconds and 4 minutes on a Windows system depending on the registry setting) will allow a socket gracefully. Until this is done, you cannot re-use the socket object.

    Usually you create a new socket and assign the current connection to this newly created socket instead of having one permanent client socket...

  5. #5
    Join Date
    Sep 2003
    Posts
    82
    ok......thanks for the info....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured