-
No matter what I do I can not get one winsock to connect to another. I have one application with a winsock called WinS on it and on another computer with a different IP address I have another application with a winsock on it called WinS. They are both set as TCP and one app is listining on port 7777 and the other one is trying to connect to the other one using the same port and the Ip address as the remote host. It never connects. I've got a status bar on it so I can tell what its doing and it says it's connecting then It just times out and gives an error. I ve got it set up to accept the requested ID on the one thats listening. I have my fire wall shut down so thats not it. Any one got a clue?
-
If you post those portions of your code, it would be much easier to find the problem.
Sunny
-
ok here it is
Private Sub Form_Load()
On Error Resume Next
WinS.LocalPort = 7777
WinS.Listen
End Sub
Private Sub WinS_Connect()
Form1.Text7.Text = "Connected"
End Sub
Private Sub WinS_ConnectionRequest(ByVal requestID As Long)
If WinS.State <> sckClosed Then WinS.Close
WinS.Accept requestID
End Sub
and the other winsock
Private Sub Form_Load()
WinS.Connect Form1.Text1.Text, 7777
*// form1.text1.text is the IP# of the other winsock//
End Sub
Private Sub Timer2_Timer()
Dim strState As String
Select Case WinS.State
Case sckClosed
strState = "Closed"
Case sckOpen
strState = "Open"
Case sckListening
strState = "Listening"
Case sckConnectionPending
strState = "Connection pending"
Case sckResolvingHost
strState = "Resolving host"
Case sckHostResolved
strState = "Host resolved"
Case sckConnecting
strState = "Connecting"
Case sckConnected
strState = "Connected"
Case sckClosing
strState = "Peer is closing the connection"
Case sckError
strState = "Error"
End Select
Form1.StatusBar1.Panels(2).Text = strState
End Sub
when I try to connect I get "error"
What am I doing wrong?
-
So it seems that the error occuring isn't one of the states of Winsock. Use this to get the exact error, it'll start to point you in the right direction.
Code:
Private Sub WinS_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
MsgBox Number & " " & Description
End Sub
Sunny