|
Repost from accidental post to Midrange-L:
I'm using Scott Klement's socket tutorial as the template for a socket server that uses non-blocking sockets with select() to support multiple (3) clients at once.
Right now I have only one client active, but for some reason when I receive data, I receive the same data string x number of times over a short period of minutes and in one instance over a period of about 50 minutes.
For example one message was received 23 times (in a row) and the next one 27 times. Following that the next five unique messages were received 27, 30, 14, 27 & 26 times (each received x number of times in a row).
The client says they are not responsible for sending the same data repeatedly.
I'm wondering if the following code inserted into this subroutine in the template to read & write to the buffers is incorrect and responsible for this problem.
Is this not the correct location (note code prefixed with gpk) to be reading the input buffers and writing the output buffers?
sk CSR CheckSockets begsr sk C*------------------------ sk c do MAXCLIENTS C sk sk c C occur client sk sk c if sock <> -1 sk sk c if FD_ISSET(sock: readset) sk c if ReadClient(C) < 0 sk c callp EndClient(C) sk c callp FD_CLR(sock: excpset) sk c callp FD_CLR(sock: writeset) gpk * Load socket data from input buffer, do custom processing, gpk * and load the ACK to the output buffer... gpk C Else gpk C Eval IscketData = *Blanks
gpk C Eval IscketData = rdbuf gpk C Exsr ReadIscket gpk C Eval wrbuflen = %Len(OscketData) gpk C Eval wrbuf = OscketData sk c endif sk c endif sk sk c if FD_ISSET(sock: writeset) sk c if WriteClient(C) < 0 sk c callp EndClient(C) sk c callp FD_CLR(sock: excpset) sk c callp FD_CLR(sock: writeset) sk c endif sk c endif sk sk c if FD_ISSET(sock: excpset) sk c callp EndClient(C) sk c endif sk sk c endif sk sk c enddo sk C*------------------------ sk CSR endsr
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.