Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Debugging an OLE service
Message
 
To
23/08/2007 12:41:03
Jay Johengen
Altamahaw-Ossipee, North Carolina, United States
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Environment versions
Visual FoxPro:
VFP 8 SP1
Miscellaneous
Thread ID:
01249928
Message ID:
01249938
Views:
13
>>I do not know why your code does not error out, for me it does if I use this.oSock.Object.Accept() or any reference to this.oSock.Object, I write all like this.oSock.Accept() (no object, I believe object is valid when you put the ActiveX container in your forms, but I might be wrong)
>
>Basically, I have this making the call. There is code earlier that sets the variables like m.Port, etc. The oxServer object is created and the client utility doesn't error out, which tells me it is talking to the port. I just can't find a way to go through the code to see what is/isn't being run.
>


Jay,

Run the code below, it should work as it does for me. Now change any reference of a method adding Object like you are using, for example use this.oSock.Object.Accept(), doesn't it error out?
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, oxServer.oSock.LocalPort)
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
Inkey(2)
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
		? 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
Next
Reply
Map
View

Click here to load this message in the networking platform