>clear >oxServer = CREATEOBJECT( "EMPS_Class" ) >oxServer.Setup() >oxServer.oSock.LocalPort = 6565 >oxServer.oSock.Listen() >? 'Server State', oxServer.oSock.State > >ox = CREATEOBJECT( "EMPS_Class" ) >ox.Setup() >ox.oSock.Connect(oxServer.oSock.LocalIP, 6565) >lnStart = Seconds() >do while ox.oSock.State = 6 and Seconds() - lnStart <= 5 > doevents >enddo > >? 'Client State', ox.oSock.State, 'Elapsed time: ', Seconds() - lnStart >if ox.oSock.State = 7 > ox.oSock.SendData("This is a test.") >endif > >ox.oSock.close() >oxServer.oSOck.Close() > >********************************************************** >DEFINE CLASS EMPS_Class AS SESSION OLEPUBLIC >********************************************************** > > IMPLEMENTS DMSWinsockControlEvents IN "c:\windows\system32\mswinsck.ocx" > > ********************************************************** > PROCEDURE DMSWinsockControlEvents_Error(NUMBER AS INTEGER, DESCRIPTION AS STRING, Scode AS NUMBER, SOURCE AS STRING, HelpFile AS STRING, HELPCONTEXT AS NUMBER, CancelDisplay AS LOGICAL) AS VOID HELPSTRING "Error occurred" > * add user code here > ENDPROC > > > ********************************************************** > PROCEDURE DMSWinsockControlEvents_DataArrival(bytesTotal AS NUMBER) AS VOID HELPSTRING "Occurs when data has been received from the remote computer" > > strData = SPACE(256) && Define string to pass to GetData > > THIS.oSock.GETDATA(@strData) > > * Testing code to parse HL7 billing data from Medinotes Client to EM tables > ? 'Data received: ', strData > > ENDPROC > > > ********************************************************** > PROCEDURE DMSWinsockControlEvents_Connect() AS VOID HELPSTRING "Occurs connect operation is completed" > * add user code here > ? 'Connected' > ENDPROC > > > ********************************************************** > PROCEDURE DMSWinsockControlEvents_ConnectionRequest(requestID AS NUMBER) AS VOID HELPSTRING "Occurs when a remote client is attempting to connect" > > #DEFINE sckClosed 0 > > ? 'Connection accepted', requestID > IF THIS.oSock.State <> sckClosed > THIS.oSock.CLOSE > ENDIF > > *!* Accept the request with the requestID > *!* parameter. > THIS.oSock.ACCEPT(requestID) > > ENDPROC > > > ********************************************************** > PROCEDURE DMSWinsockControlEvents_Close() AS VOID HELPSTRING "Occurs when the connection has been closed" > * add user code here > ? 'Closed' > ENDPROC > > > ********************************************************** > PROCEDURE DMSWinsockControlEvents_SendProgress(bytesSent AS NUMBER, bytesRemaining AS NUMBER) AS VOID HELPSTRING "Occurs during process of sending data" > * add user code here > > ENDPROC > > > ********************************************************** > PROCEDURE DMSWinsockControlEvents_SendComplete() AS VOID HELPSTRING "Occurs after a send operation has completed" > * add user code here > > ENDPROC > > > oSock = NULL > > > ********************************************************** > PROCEDURE INIT > > THIS.oSock = CREATEOBJECT("MSWinsock.Winsock.1") > > procedure setup > if EVENTHANDLER(THIS.oSock, THIS) > ? 'Event handler succeeded' > else > ? 'Event handler failed' > endif > ENDPROC > >ENDDEFINE >