Port 0 is a special wildcard that allows a socket to bind to a random available ephimeral port. After the binding is successful, you can query the socket to discover which actual port it bound to. As such, you cannot connect a client socket to port 0, because it is not possible for a server socket to listen on port 0 in the first place.
Different behavior in connecting to port 0 in windows 2008 32/64 bit [closed]
-
09-03-2022 - |
Question
When I run the below code in windows 2008 32 bit server, program flow goes to sckTest_Error() when connect() is called.
But when I run the same code in windows 2008 64 bit server, RTE occurs and program flow goes to error:
Private Sub Form_Load()
On Error GoTo error1
If (Not (Me.sckTest.State = sckConnected)) Then
'
'Log event for outbound client mode connectoin
If Me.sckTest.State <> sckClosed Then
Me.sckTest.Close
End If
'
MsgBox "Going to connect"
Me.sckTest.Connect "127.0.0.1", 0
MsgBox "Connecting"
If Me.sckTest.State = sckConnected Then
MsgBox "Connected"
End If
'
End If
Exit Sub
error1:
MsgBox "RTE " & Err.Number
End Sub
Private Sub sckTest_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 "Error in connecting" & Number
End Sub
But I get error as 10049 in both servers. Can any please advice its the problem with my code or server behavior.
Thanks
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow