Menu

SocketService / SocketPort / tcpservice

Help
2001-05-01
2001-05-01
  • Nick Liebmann

    Nick Liebmann - 2001-05-01

    Hi,
    I am having problems using the SocketService / SocketPort classes. The problem also seems to appear in the tcpservice demo. There also seem to be references to this problem in this forum for earlier versions of CommonC++.

    My system is LinuxMandrake 2.2.19 i586 unknown

    TEST CASE:
    Start 3 consoles!
    run the tcpservice demo in console 1
    telnet localhost 3999 in console 2
    telnet localhost 3999 in console 3

    The second telnet session thinks it has got a connection,
    but from the messages in the server window I can see that the 'ChatterSession' has not been created.
    Once data has been sent from the first session the ChatterSession is created. And things work fine.

    It looks to me as though notification of a new connection is not interrupting the read operation, or causing the SocketService to stall.

    Does anyone have any ideas?

    Thanks

    Nick

     
    • Nick Liebmann

      Nick Liebmann - 2001-05-01

      I have since found that a call to
      setDetectOutput(true) in the derived constructor for the SocketPort fixes this problem.

      Does anyone know of any problems with this solution!

       
      • Nick Liebmann

        Nick Liebmann - 2001-05-01

        There is also a problem with disconnecting and then reconnecting to the server.

        The tcpservice demo quits when all connections are closed, so you need to remove the
        mainsem->Post() call in CCExec::ListDepleted() to test this.

        Make a connection to the tcpservice server and then close the connection.
        Then try to make another connection...it fails and the server seems to have hanged.

        I have traced this back to a dodgy call to the poll function in SocketService::Run(). (also noticed by 'swoolford ( Stuart Woolford )' in an earlier post.)

        At line ~425 in file port.cpp...the following code fixes the problem, although a mutex / event based solution would be more efficient.

        if(first)
            poll(mfd.getList(), count + 1, timer);
        else
            pthread_yield();

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.