Winsock control

J

Jim Franklin

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
 
D

David W. Fenton

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top