Author Topic: Open socket after disconnecting Client  (Read 5454 times)

PjotrvA

  • User
  • *
  • Posts: 5
Open socket after disconnecting Client
« on: November 07, 2006, 03:28:42 AM »
Hi,

I'm also developing network connections in Delta3D.

I have a server running, accepting connections.

If I disconnect a client, it seems the socket is not closed after receiving a OnDisconnect in the derived ConnectionListener.
If I check the log, it seems GNE is not able to send the complete ExitPacket.

I call disconnectSendAll from the client with a timeout of 2 seconds. Since both programs run on the same computer, I think the timeout is long enough.

After calling disconnect, I also call the functions:

GNE::Connection::disconnectAll();
GNE::Timer::stopAll();
GNE::Thread::requestAllShutdown(GNE::Thread::USER);

Can this be my problem?

When I stat a new client, the client is not able to connect to the server. It passes an error of Adress already in use.
If I check with ActivePorts, I can see a client port open to the server. It has a status of TIME_WAIT, Unknown process with PID: 0???
After some time (a few minutes) The socket disappears....

How do I disconnect my client correctly??

gr. PjotrvA

PjotrvA

  • User
  • *
  • Posts: 5
Re: Open socket after disconnecting Client
« Reply #1 on: November 07, 2006, 05:00:35 AM »
I forgot to include logfile entries:

This portion is of the disconnect sequence of the client!

             EventThread.cpp, line  146, thrd EventGen: 13a2650: onReceive event triggered.
             EventThread.cpp, line  146, thrd EventGen: 13a2650: onReceive event triggered.
             EventThread.cpp, line  146, thrd EventGen: 13a2650: onReceive event triggered.
              Connection.cpp, line  361, thrd     main: 13a13b8: Unregistered reliable socket 0
              Connection.cpp, line  123, thrd     main: 13a13b8: disconnecting r: 0, u: -1
            PacketStream.cpp, line  325, thrd  PktStrm: 13a32f0: ExitPackt not completely sent (2).
                  Thread.cpp, line  112, thrd  PktStrm: 13a32f0: Thread PktStrm Ending
             EventThread.cpp, line  103, thrd     main: 13a2650: onDisconnect Event triggered.
                  Thread.cpp, line  112, thrd EventThr: 13a2650: Thread EventThr Ending
             EventThread.cpp, line   57, thrd     main: 13a2650: destroyed
        ClientConnection.cpp, line   59, thrd     main: 13a13b8: destroyed
                  Thread.cpp, line  138, thrd     main: 13a13ec: Thread destroyed
            PacketStream.cpp, line   96, thrd     main: 13a32f0: destroyed
                  Thread.cpp, line  138, thrd     main: 13a32f0: Thread destroyed
                  Thread.cpp, line  138, thrd     main: 13a2650: Thread destroyed
                     GNE.cpp, line   97, thrd     main: Shutting down CEG.
                     GNE.cpp, line  103, thrd     main: GNE Shutdown begin: Closing all listeners.
                     GNE.cpp, line  105, thrd     main: Shutting down all connections.
                     GNE.cpp, line  107, thrd     main: Stopping all timers.
                     GNE.cpp, line  109, thrd     main: Shutting down all user threads.
                     GNE.cpp, line  112, thrd     main: Waiting up to 1000 ms for all threads to shutdown.
                     GNE.cpp, line  119, thrd     main: CEG failed to shut down properly!  Please file a bug report.
                     GNE.cpp, line  124, thrd     main: Shutting down HawkNL.
                     GNE.cpp, line  131, thrd     main: GNE Shutdown



Gillius

  • Administrator
  • User
  • *****
  • Posts: 147
    • http://www.gillius.org/
Re: Open socket after disconnecting Client
« Reply #2 on: November 07, 2006, 09:14:44 AM »
What version of GNE are you using?
Gillius
Gillius's Programming http://www.gillius.org/

Gillius

  • Administrator
  • User
  • *****
  • Posts: 147
    • http://www.gillius.org/
Re: Open socket after disconnecting Client
« Reply #3 on: November 07, 2006, 09:34:04 AM »
You can check out the changes log file https://svn.sourceforge.net/svnroot/gnelib/trunk/Changes. I don't see anything related to this in here but since 0.70 (maybe I forgot to add it to the file) I thought I remember fixing a bug related to shutting down GNE and restarting it again, although that's not your problem here I wonder if it is related.

What bothers me is that the CEG isn't shutting down properly which could be a bug in GNE. In the latest GNE I think all of the events go through the event thread and onReceive isn't processed from the CEG anymore so I'm not sure you can be blocking it with your own code.

But it would help me to know what version you are running and what platform you are on (Lin/Win/Solaris)
Gillius
Gillius's Programming http://www.gillius.org/

PjotrvA

  • User
  • *
  • Posts: 5
Re: Open socket after disconnecting Client
« Reply #4 on: November 08, 2006, 03:37:36 AM »
Thanks for your help,

I'm using GNE 0.70 which is included in the Delta3D SDK.
I'm developing on a windows environment (WinXP, Visual Studio 2003) , but the code should be used on all platforms supported by Delta3D.

In the client, I am shutting down GNE and restarting it.
The server keeps running on the same computer without a problem.

thnx Pjotr

Gillius

  • Administrator
  • User
  • *****
  • Posts: 147
    • http://www.gillius.org/
Re: Open socket after disconnecting Client
« Reply #5 on: November 08, 2006, 08:36:08 AM »
OK, then you are using 0.70... Can you try to see if the problem happens with the latest version? Or have my answers so far resolved it for you?

I'm currently working to get a new release for the end of November.
Gillius
Gillius's Programming http://www.gillius.org/