Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Winsock control

11 views
Skip to first unread message

Jim Franklin

unread,
Sep 8, 2010, 12:55:05 PM9/8/10
to
Hi,

I am running an Access 2003 app with a form that uses the Winsock control to
communicate with an external controller.

My code sends data to the Winsock control using the .SendData method. A
response then comes back.

I have the following code for the winsock control events:

Private Sub ctlWinsock1_Close()
Winsock1.Close
Winsock1.Listen
Me.txtStatus = "Listening."
End Sub

Private Sub ctlWinsock1_ConnectionRequest(ByVal requestID As Long)
If Winsock1.State <> sckClosed Then
Winsock1.Close
End If
Winsock1.Accept requestID
Me.txtStatus = "Connected."
End Sub

Private Sub ctlWinsock1_DataArrival(ByVal bytesTotal As Long)
Winsock1.GetData inData
inData = ProcessXML(inData)
Winsock1.Close
Winsock1.Listen
ProcessInData
End Sub

I then use ProcessInData to carry out instructions based on the inData
string that comes back.

However my code that runs the .SendData command continues running without
waiting for the winsock events to run. Ideally I would like to pause the
code after the SendData command until the response has come back. i.e. I
would like my ProcessInData call to be after my winsock.SendData command in
the same procedure, rather than being in the DataArrival event of the
winsock control.

Can anyone tell me how to do this? As you can probably tell, I am not used
to using the Winsock control.

Many thanks (again!)

Jim


David W. Fenton

unread,
Sep 8, 2010, 4:10:25 PM9/8/10
to
"Jim Franklin" <byeby...@ntlworld.com> wrote in
news:OdPho.37628$Hv6....@newsfe04.ams2:

> However my code that runs the .SendData command continues running
> without waiting for the winsock events to run. Ideally I would
> like to pause the code after the SendData command until the
> response has come back. i.e. I would like my ProcessInData call to
> be after my winsock.SendData command in the same procedure, rather
> than being in the DataArrival event of the winsock control.
>
> Can anyone tell me how to do this? As you can probably tell, I am
> not used to using the Winsock control.

What are the possible values for Winsock1.State? Surely you could
test for that and only continue your code when the state value
returned is appropriate to do the rest of what your code needs to
do.

--
David W. Fenton http://www.dfenton.com/
contact via website only http://www.dfenton.com/DFA/

0 new messages