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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
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
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!
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();