Hello,
I too have run into this problem and I hope some of the following might be
helpful.
My client server application posts null terminated UTF8 string messages back
and forth. It would work for a while, then just lock up.
I have modified the sample code client/server example to show the problem
sockets.zip <
http://wxwidgets.10942.n7.nabble.com/file/n86640/sockets.zip>
- my hack has added a "test 4" where the client responds to each reply from
the server by sending a new message. This would be expected to run
indefinitely, but stops after a few rounds.
Server shows:
...
20:57:19: === Test 4 begins ===
20:57:19: Got the data " Test 4 pass No. 16". Sending it back
20:57:19: === Test 4 ends ===
OnSocketEvent: wxSOCKET_INPUT
20:57:19: === Test 4 begins ===
20:57:19: Got the data " Test 4 pass No. 17". Sending it back
20:57:19: === Test 4 ends ===
OnSocketEvent: wxSOCKET_INPUT
20:57:19: === Test 4 begins ===
20:57:19: Got the data " Test 4 pass No. 18". Sending it back
20:57:19: === Test 4 ends ===
Client shows:
...
=== Test 4 pass done. ===
Sending "Test 4 pass No. 16" to the server ...done
20:57:19: Input available on the socket
Socket input event.Receiving the buffer back from server ...done
Test 4 pass No. 16
=== Test 4 pass done. ===
Sending "Test 4 pass No. 17" to the server ...done
20:57:19: Input available on the socket
Socket input event.Receiving the buffer back from server ...done
Test 4 pass No. 17
=== Test 4 pass done. ===
Sending "Test 4 pass No. 18" to the server ...done
20:57:19: Input available on the socket
Socket input event.Receiving the buffer back from server ...done
Test 4 pass No. 18
=== Test 4 pass done. ===
Sending "Test 4 pass No. 19" to the server ...done
As can be seen, the client believes it has sent pass number 19, but there is
no input event at the server.
My first guess was that there was a problem with repeatedly disabling and
enabling input events - perhaps a timing problem where the data arrives
while the input event is being enabled, and fails to trigger the event.
I modified my original application to keep events permanently enabled. It
now reads all data available into a fifo, and pulls out complete messages
when available. I have not yet seen this fail.
I assumed I could fix my hacked sample code in the same way. I tried
removing the
sock->SetNotify(wxSOCKET_LOST_FLAG);
lines. Although this works for longer, it still fails fairly quickly.
I must admit that I don't understand how this should work I see that
sock->SetNotify() simply changes a member variable, so I don't see how
another input event would be generated if a message had been received
between the read and re-enabling input events.
I hope this contains some useful clue for someone that does understand
This was done with wxWidgets 3 on Windows 7, built with Mingw.
Regards
Jim
--
View this message in context:
http://wxwidgets.10942.n7.nabble.com/Socket-sample-server-stop-receiving-input-event-tp84310p86640.html
Sent from the wxWidgets - Users mailing list archive at Nabble.com.