Hi,

I have a single machine with 2 network adapters. I started a VB application. On my main form, I have 2 WINSOCK controls - sock1 and sock2. I have bound each control to different network adapters.

I am trying to emulate a client-server architecture on this machine. I am new to this and followed an online tutorial. Below is the code. The problem I am having is that the connection state for my sever socket (sock1) is 7, but the connection state for my client socket (sock2) is always 6=sckConnecting.

Please HELP !!!!

Thanks.

------------------------------------------------------------------------

Private Sub Form_Load()

' Close sockets is not closed
If sock1.State <> sckClosed Then
sock1.Close
End If
If sock2.State <> sckClosed Then
sock2.Close
End If

' Set protocol used for communication
sock1.Protocol = sckTCPProtocol
sock2.Protocol = sckTCPProtocol

' Set Local and Remote host properties for sock1 = server
sock1.Bind 5014, "11.12.13.14"

' Set Local and Remote host properties for sock2 = client
sock2.RemotePort = 5014
sock2.RemoteHost = "11.12.13.14"
sock2.Bind 5015, "11.12.13.15"

End Sub

--------------------------------------------------------------------

Private Sub cmdCancel_Click()

If sock1.State <> sckClosed Then
sock1.Close
End If
If sock2.State <> sckClosed Then
sock2.Close
End If

End

End Sub

--------------------------------------------------------------------

Private Sub cmdStartClient_Click()

If sock2.State <> sckClosed Then
sock2.Close
End If

' Set the client in connect mode
sock2.Connect

End Sub

--------------------------------------------------------------------

Private Sub cmdStartServer_Click()

' Close sockets if not closed
If sock1.State <> sckClosed Then
sock1.Close
End If

' Set the server in listen mode
sock1.Listen

End Sub

--------------------------------------------------------------------

Private Sub sock1_ConnectionRequest(ByVal requestID As Long)

MsgBox "Request received by client to connect. Checking current connections..."

' Check the state of the current socket connection. If not closed, close it
If sock1.State <> sckClosed Then
sock1.Close
End If

sock1.Accept requestID
MsgBox "Connection accepted"

MsgBox sock1.State
MsgBox sock2.State - This is where it shows a state of 6
End Sub

--------------------------------------------------------------------

Private Sub cmdTransmit_Click()

' Client sending the data
sock2.SendData txtDataPattern.Text

End Sub

--------------------------------------------------------------------

Private Sub sock1_DataArrival(ByVal bytesTotal As Long)

Dim temp

' Server receiving the data
sock1.GetData temp, vbString

End Sub

--------------------------------------------------------------------

Private Sub sock2_DataArrival(ByVal bytesTotal As Long)

Dim temp

' Server receiving the data
sock2.GetData temp, vbString

End Sub

--------------------------------------------------------------------