I have a problem that has shown up whilst load testing sockets in that the speed of the socket response becomes slower after each request.
First time I've used sockets so hopefully the technique is OK.
I am on 10.2a, appserver, unix server.
Client side code. (client.p)
Server side code. (server.p)
I have load tested this by running
If I run this load test several times the socket takes longer & longer. I have a 'feeling' that I'm not disconnecting correctly or tidying something up but am stuck as to what this is.
I am running the server socket on a V9 db and passing info back to the v10 client.
Sorry it's so long but any help would be appreciated.
Thanks.
First time I've used sockets so hopefully the technique is OK.

I am on 10.2a, appserver, unix server.
Client side code. (client.p)
Code:
DEFINE VARIABLE mytext AS CHARACTER NO-UNDO.
DEFINE VARIABLE i AS INTEGER NO-UNDO.
DEFINE VARIABLE mysocket AS HANDLE NO-UNDO.
DEFINE VARIABLE mymemptr AS MEMPTR NO-UNDO.
DEFINE VARIABLE ret AS LOGICAL NO-UNDO.
DEFINE VARIABLE iMemmorySize AS INTEGER NO-UNDO INITIAL 15.
CREATE SOCKET mysocket.
ret = mysocket:CONNECT("-H dev -S 6666").
IF NOT ret THEN DO:
MESSAGE "Unable to connect to server" VIEW-AS ALERT-BOX.
END.
/* Build a message to send */
mytext = "Hello".
SET-SIZE(mymemptr) = iMemmorySize.
SET-BYTE-ORDER(mymemptr) = BIG-ENDIAN.
PUT-STRING(mymemptr, 1, iMemmorySize) = mytext.
mysocket:WRITE(mymemptr, 1, GET-SIZE(mymemptr)).
SET-SIZE(mymemptr) = 0.
mytext = "Goodbye".
SET-SIZE(mymemptr) = iMemmorySize.
SET-BYTE-ORDER(mymemptr) = BIG-ENDIAN.
PUT-STRING(mymemptr, 1, iMemmorySize) = mytext.
mysocket:WRITE(mymemptr, 1, GET-SIZE(mymemptr)).
SET-SIZE(mymemptr) = 0.
SET-SIZE(mymemptr) = iMemmorySize.
SET-BYTE-ORDER(mymemptr) = BIG-ENDIAN.
mysocket:READ(mymemptr,1,iMemmorySize).
mytext = GET-STRING(mymemptr,1,iMemmorySize).
MESSAGE "The message is: " + TRIM(mytext) VIEW-AS ALERT-BOX.
SET-SIZE(mymemptr) = 0.
mysocket:DISCONNECT(). /* Point 5 */
DELETE PROCEDURE THIS-PROCEDURE.
DELETE OBJECT mysocket.
Server side code. (server.p)
Code:
CREATE SERVER-SOCKET mysocket NO-ERROR.
ret = mysocket:ENABLE-CONNECTIONS("-S 6666").
mysocket:SET-CONNECT-PROCEDURE("ConnectionProcedure").
WAIT-FOR "CLOSE" OF THIS-PROCEDURE.
DELETE OBJECT mysocket.
PROCEDURE ConnectionProcedure:
DEFINE INPUT PARAM clienthandle AS HANDLE.
clienthandle:SET-READ-RESPONSE-PROCEDURE("readProcedure").
END PROCEDURE.
PROCEDURE readProcedure:
/* Command / Instruction */
SET-SIZE(mymemptr) = iMemmorySize.
SET-BYTE-ORDER(mymemptr) = BIG-ENDIAN.
SELF:READ(mymemptr,1,iMemmorySize).
gcCommandText = GET-STRING(mymemptr,1,iMemmorySize).
SET-SIZE(mymemptr) = 0.
/* Find Data */
SET-SIZE(mymemptr) = iMemmorySize.
SET-BYTE-ORDER(mymemptr) = BIG-ENDIAN.
SELF:READ(mymemptr,1,iMemmorySize).
gcDataText = GET-STRING(mymemptr,1,iMemmorySize).
SET-SIZE(mymemptr) = 0.
ASSIGN gcDataText = "From Server".
RUN returnmessage(INPUT gcDataText).
SELF:DISCONNECT().
END PROCEDURE.
PROCEDURE returnMessage:
DEFINE INPUT PARAMETER pcClientText AS CHARACTER NO-UNDO.
/* Build a message to send */
SET-SIZE(mymemptr) = iMemmorySize.
SET-BYTE-ORDER(mymemptr) = BIG-ENDIAN.
PUT-STRING(mymemptr, 1, iMemmorySize) = pcClientText.
SELF:WRITE(mymemptr, 1, GET-SIZE(mymemptr)).
SET-SIZE(mymemptr) = 0.
SELF:DISCONNECT().
END PROCEDURE.
I have load tested this by running
Code:
DEF VAR iCount AS INTEGER NO-UNDO.
DO iCount = 1 to 200:
RUN client.p.
END.
If I run this load test several times the socket takes longer & longer. I have a 'feeling' that I'm not disconnecting correctly or tidying something up but am stuck as to what this is.
I am running the server socket on a V9 db and passing info back to the v10 client.
Sorry it's so long but any help would be appreciated.
Thanks.