I have been using PortNumber 55001 flawlessly for years and today this will not run on my Windows 10 PC (same machine I have been using for years). This is part of a server setup using TCP to service clients on a private local network. My PC will now crash on the indicated line using portNumber = 55001.
My code:
Code:
'create a new listener instance bound to the desired address and port
listener = New TcpListener(IPAddress.Any, portNumber)
'start the listener
listener.Start() '<======== CRASHES HERE
'begin accepting clients until the listener is closed
The very same code is still working fine on my Windows surface laptop ... without any trouble.
What could have caused this to no longer work ?
The ERROR message generated is:
Code:
System.Net.Sockets.SocketException
HResult=0x80004005
Message=Only one usage of each socket address (protocol/network address/port) is normally permitted
Source=System
StackTrace:
at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.Sockets.Socket.Bind(EndPoint localEP)
at System.Net.Sockets.TcpListener.Start(Int32 backlog)
at System.Net.Sockets.TcpListener.Start()
at MRCTcpServerApp.frmControlPanel.VB$StateMachine_169_startButton_Click.MoveNext() in C:\Users\Montgomery\Desktop\MRC Files\Visual Basic Files\VisualStudio Files\intersSWIM Server\MRCTcpServerApp\Form2.vb:line 114
This exception was originally thrown at this call stack:
[External Code]
MRCTcpServerApp.frmControlPanel.startButton_Click(Object, System.EventArgs) in Form2.vb
Any ideas what has gone wrong and how to fix it ??? .... I know the code is perfectly fine since it has worked for years (and still works on my laptop). I am using VS 2019 with version 16.8.3.