I've written a vb program that will connect to a server using sckTCPProtocol and send a string and obtain the response string. However it requires user input. Before I can think about creating a dll (for a web server) I need the exe to perform the whole process by itself.
Here's the form code:
--------------------------------------------------
Private Sub cmdDoAll_Click()
cmdConnect_Click
cmdSend_Click
cmdDisconnect_Click
End Sub
Private Sub cmdExit_Click()
Debug.Print "winsock state before end: " & Winsock1.State
End
End Sub
Private Sub cmdConnect_Click()
'connect to the server
Winsock1.Connect
Debug.Print "winsock state after connect: " & Winsock1.State
End Sub
Private Sub cmdDisconnect_Click()
'disconnect from server
Winsock1.Close
Debug.Print "winsock state after close: " & Winsock1.State
End Sub
Private Sub cmdSend_Click()
Dim myString As String
'define string to send
myString = Chr(1) & "adavids2 nthorp N N testingtcp" & Chr(10)
Debug.Print "myString = " & myString
'send the string to the server
Winsock1.SendData myString
End Sub
Sub winsock1_connect()
'this runs when the client has connected successfully to the server
Debug.Print "winsock state after winsock1_connect function: " & Winsock1.State
End Sub
Sub Winsock1_SendComplete()
'this runs when the string has been sent to the server
Debug.Print "winsock state after sendcomplete: " & Winsock1.State
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
'this runs when a reply is received from the server
'sets in_data to equal the reply from the server
Winsock1.GetData in_data, vbString, bytesTotal
Debug.Print in_data
End Sub
---------------------------------------------------------
The program works fine and in_data gets populated with the reply from the server if the user clicks on cmdConnect and then clicks on cmdSend. (winsock1_connect runs in this scenario)
However, if user clicks on cmdDoAll the winsock state hangs at 6 (connecting) and the send fails. winsock1_connect doesn't run.
Can anyone help as to why the winsock state never reaches 7 (connected)?
also, just noticed that if I put a watch on winsock1.state then I get the same error for the method that does work.
congrats and thanks if you got this for!
Here's the form code:
--------------------------------------------------
Private Sub cmdDoAll_Click()
cmdConnect_Click
cmdSend_Click
cmdDisconnect_Click
End Sub
Private Sub cmdExit_Click()
Debug.Print "winsock state before end: " & Winsock1.State
End
End Sub
Private Sub cmdConnect_Click()
'connect to the server
Winsock1.Connect
Debug.Print "winsock state after connect: " & Winsock1.State
End Sub
Private Sub cmdDisconnect_Click()
'disconnect from server
Winsock1.Close
Debug.Print "winsock state after close: " & Winsock1.State
End Sub
Private Sub cmdSend_Click()
Dim myString As String
'define string to send
myString = Chr(1) & "adavids2 nthorp N N testingtcp" & Chr(10)
Debug.Print "myString = " & myString
'send the string to the server
Winsock1.SendData myString
End Sub
Sub winsock1_connect()
'this runs when the client has connected successfully to the server
Debug.Print "winsock state after winsock1_connect function: " & Winsock1.State
End Sub
Sub Winsock1_SendComplete()
'this runs when the string has been sent to the server
Debug.Print "winsock state after sendcomplete: " & Winsock1.State
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
'this runs when a reply is received from the server
'sets in_data to equal the reply from the server
Winsock1.GetData in_data, vbString, bytesTotal
Debug.Print in_data
End Sub
---------------------------------------------------------
The program works fine and in_data gets populated with the reply from the server if the user clicks on cmdConnect and then clicks on cmdSend. (winsock1_connect runs in this scenario)
However, if user clicks on cmdDoAll the winsock state hangs at 6 (connecting) and the send fails. winsock1_connect doesn't run.
Can anyone help as to why the winsock state never reaches 7 (connected)?
also, just noticed that if I put a watch on winsock1.state then I get the same error for the method that does work.
congrats and thanks if you got this for!