Hello,
I am new to VB.Net. I bought this book "Network Programming in .Net" by Fiach Reid, to become familiar with VB and .Net. Anywho, I am testing one of his examples where you create a client that xfers a file to the server. What a great example. So I go ahead and type it in character for character, when I start to run the server in debug it stops at tcpListener.Start()
Here is the method
The error I get in VB is
SocketException - only one usage of each socket address (protocol/network address/port) is normally permitted.
I am having trouble seeing the problem. Could someone point it out?
Thanks
I am new to VB.Net. I bought this book "Network Programming in .Net" by Fiach Reid, to become familiar with VB and .Net. Anywho, I am testing one of his examples where you create a client that xfers a file to the server. What a great example. So I go ahead and type it in character for character, when I start to run the server in debug it stops at tcpListener.Start()
Here is the method
Code:
Public Sub listenerThread()
Dim myHost As System.Net.IPHostEntry = Dns.GetHostEntry("localhost")
Dim myIP As System.Net.IPAddress = myHost.AddressList(0)
Dim tcpListener As New TcpListener(myIP, 80)
Dim handlerSocket As Socket
Dim thdstHandler As ThreadStart
Dim thdHandler As Thread
tcpListener.Start()
Do
handlerSocket = tcpListener.AcceptSocket
If handlerSocket.Connected Then
lbConnections.Items.Add(handlerSocket.RemoteEndPoint.ToString() + "Connected.")
SyncLock (Me)
alSockets.Add(handlerSocket)
End SyncLock
thdstHandler = New ThreadStart(AddressOf handlerThread)
thdHandler = New Thread(thdstHandler)
thdHandler.Start()
End If
Loop
End Sub
The error I get in VB is
SocketException - only one usage of each socket address (protocol/network address/port) is normally permitted.
I am having trouble seeing the problem. Could someone point it out?
Thanks