|
-
Jan 29th, 2008, 05:23 PM
#1
Thread Starter
Junior Member
[RESOLVED] VB.Net TCPClient Connection Error 10049
Hey,
I'm trying to make a server/client application that uses a TcpListener on the server-side which listens on my WAN IP (using IPAddress.Any method) and port 3000, and a TcpClient on the client-side, which connects to the server using a tcpClient.Connect(ipString, portNo), but this blocks for a number of seconds, after which it throws the error:
A connection attempt failed because the connected party did not respond properly after a period of time, or established connection failed because connected host has failed to respond.
A few points:
- I have checked, using the VS debugger, that IPAddress.Any definitely uses my WAN IP.
- When the TcpListener is not listening (ie. inactive), the same error is thrown by the client.
- I am running the server on my home computer and am using a router.
- I have tried configuring the DMZ setting of my router to allow access to my computer.
- I have also attempted to set up port-forwarding, but I don't know if I've done this correctly.
My code, if you need it:
Server
Code:
Dim port As Int32 = 3000
Dim server As TcpListener
Dim aClient As TcpClient
Try
server = New TcpListener(IPAddress.Any, port)
Catch ex As Exception
MsgBox("Could not initialise server: " & ex.Message)
End Try
Try
server.Start()
lblStatus.Text = "Waiting for connections..."
Catch ex As Exception
MsgBox("Could not start server: " & ex.Message)
End Try
If server.Pending Then
Try
aClient = server.AcceptTcpClient()
Catch ex As Exception
MsgBox("Could not accept connections: " & ex.Message)
Exit Sub
End Try
Client
Code:
Dim client As New TcpClient
Try
client.Connect("82.**.***.170", 3000)
Catch ex As SocketException
MsgBox(ex.ToString, MsgBoxStyle.OkOnly, "Server Connection Error")
Exit Sub
End Try
Last edited by Nienna; Feb 1st, 2008 at 07:05 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|