|
Sigh.... I should have been a plumber....
Last week I mentioned some 'flaky-ness' with a socket server program.
This is a multi-connection socket server, and I determined that the
reason the connections weren't behaving as expected was because I
wasn't using non-blocking mode. Hence the program appeared to 'hang'
while waiting to receive data.
In my attempt to correct this problem I added code to set the socket
to non-blocked mode. In doing so, I found that after accepting a
connection (which is always 'up'), even though no data is currently
being sent (data will come as it becomes available), I exit my socket
read/write loop, without dropping the socket connection and return to
the outer loop which (I thought) should enable me to check for
incoming data on another connection (ie server shutdown request).
in doing this I found (via netstat *cnn) that multiple remote ports
(from the same remote client) are connecting to the socket server.
As a side note, my listen function is set to one, although I suspect
it should be set to two, so that it can listen to the remote client,
and also listen for a shutdown request from a different source (the
local iSeries).
But as it is now, it will shut down while connected
to the remote client and I connect locally to issue the shutdown
request with the listen value set to one.
So this morning I changed the listen value to two, shut down and
restarted and things appeared to be okay for 2.5 hours (only one
connection from the remote client showing in netstat), but when I
got back from lunch I now see two connections on different ports from
the same IP address. The remote should only be establishing one
connection should only be sending on one port.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.