Link to home
Start Free TrialLog in
Avatar of master01
master01

asked on

WinSock

How do i get Winsock to Accecpt a tcp connection request? Here is what i get so far


Private Sub Form_Load()
Winsock1.LocalPort = 1001
Winsock1.Listen
End Sub

Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
If tcpServer.State <> sckClosed Then _
tcpServer.Close
' Accept the request with the requestID
' parameter.
tcpServer.Accept requestID
End Sub

Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
aldjf = aldjf + 1
If aldjf = 1 Then
tcpServer.GetData strData1
Label1.Caption = strData1
End If
If aldjf = 2 Then
tcpServer.GetData strData2
Label2.Caption = strData2
End If
If aldjf = 3 Then
tcpServer.GetData strData3
Label3.Caption = strData3
End If
If aldjf = 4 Then
tcpServer.GetData strData4
Label4.Caption = strData4
End If
If aldjf = 5 Then
tcpServer.GetData strData5
Label5.Caption = strData5
End If
If aldjf = 6 Then
tcpServer.GetData strData6
Label6.Caption = strData6
End If
Winsock1.Close
End Sub

i have that for the server

Private Sub Command1_Click()

Winsock1.Connect
Timer1.Enabled = True
Screen.MousePointer = 11
End Sub

Private Sub Command4_Click()
Winsock1.RemoteHost = iptocall.Text
Winsock1.RemotePort = 1001
End Sub


ctttps = ctttps + 1
If ctttps = 1 Then
Winsock1.SendData Text1.Text
End If
If ctttps = 2 Then
Winsock1.SendData Text2.Text
End If
If ctttps = 3 Then
Winsock1.SendData Text3.Text
End If
If ctttps = 4 Then
Winsock1.SendData Text4.Text
End If
If ctttps = 5 Then
Winsock1.SendData Text5.Text
End If
If ctttps > 5 Then
Timer1.Enabled = False
Screen.MousePointer = 0
sgbttu.Show
End If
End Sub


can anyone help me.  I would appreciate it. Thanks in advance.

P.S.    I get a runtime error 40006 saying "Wrong protocol or connection state for the requested transaction or request."
ASKER CERTIFIED SOLUTION
Avatar of setiawan
setiawan

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial