I wrote the same program in c# sharp and works fine. When I try to do it in vb.net gives that error. Basically my application is sockets server app. I used little bit of threading with sockets. It just takes ip address and port of the client machine. I don't know it could be how the c# sharp handles threading and vb.net threading. I have the below code in form_activated event.
If clientConnectionsSocket Is Nothing Then
' Get server's details based on the name specified in DNS
Dim serverIPEntry As IPHostEntry = Dns.GetHostEntry(Dns.GetHostName())
' Get IP Address and assign it to the IP Address text box
TextBox1.Text = serverIPEntry.AddressList(0).ToString()
If IPAddress.TryParse(TextBox1.Text, validIPAddress) Then
' Create new socket to accept client connections
clientConnectionsSocket = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
'clientConnectionsSocket.Bind(New IPEndPoint(validIPAddress, Integer.Parse(glngBatchTcpPort)))
clientConnectionsSocket.Bind(New IPEndPoint(validIPAddress, 15001))
clientConnectionsSocket.Listen(MAX_CONNECTIONS)
clientConnectionsSocket.BeginAccept(New AsyncCallback(AddressOf ExecuteMeWhenAccepted), clientConnectionsSocket)
End If
End If