Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
OLE Exception code using my class
Message
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Environment versions
Visual FoxPro:
VFP 8 SP1
Miscellaneous
Thread ID:
01249645
Message ID:
01249901
Views:
19
Jay,

Just for lurkers, I found out why Data Arrival was not firing, I was not waiting for it, now with a fresh coffe I just realized about it.

If you add some delay after sending the data you'll see DataArrival firing ok.

>This almost works, still is not firing DataArrival though
>
>
>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
>
"The five senses obstruct or deform the apprehension of reality."
Jorge L. Borges?

"Premature optimization is the root of all evil in programming."
Donald Knuth, repeating C. A. R. Hoare

"To die for a religion is easier than to live it absolutely"
Jorge L. Borges
Previous
Reply
Map
View

Click here to load this message in the networking platform