Hi guys. I'm having a very serious problem. I've created Client,Server Socket applications and they work great on local mechine and I also created a test Windows Phone 7 app and configured the static IP address and the wp7 and server does connect when I run WP7 on a simulater, but the problem is with my PC client application when execued on another computer on a WAN its doesn't connect to the server.

I've open the port for both Private and public network on my firewall and also forwarded the port on my router I've used all the options available on the router for port forwarding including:

1) Virtual server.
2) Special applications
3) DMZ settings.

but still its not connecting. I'm using port number "3234".
The clien side can be downloaded here.

Any suggestion on how I can make this work?

Recommended Answers

All 24 Replies

Ow the file was a zip file. here is a part of server which listen for the incoming connections:

        Dim IPHostt As IPHostEntry
        IPHostt = Dns.GetHostByName(Dns.GetHostName)
        Form1.txtIPAddress.Text = IPHostt.AddressList(0).ToString
        Dim locIP_toStart As String = "myIPAddress here"
        Dim locIP_Address As System.Net.IPAddress = System.Net.IPAddress.Parse(locIP_toStart)
        'MsgBox(locIP_Address.ToString)
        'Form1.txtIPAddress.Text = locIP_Address.ToString
        Dim listener As New System.Net.Sockets.TcpListener(locIP_Address, localTCP_Port)
        listener.Start()

        Form1.lblStatus.Text = "Online"

        While True

            Dim tmstokvel As New TMStokvelClient(listener.AcceptTcpClient)
        End While

and here is my client which tries to connect to a server.

Do While clientSocket.Connected = False
            Try
                'clientSocket.Connect("127.0.0.1", 8888)
                'status = "Connecting..."
                'Timer2.Start()
                If clientSocket.Connected = False Then
                    Try
                        clientSocket.Connect("myServerIP here", 3234)
                        status = "Connecting..."
                        If clientSocket.Connected = True Then
                            status = "Online"
                            'Timer2.Start()
                        Else
                            status = "Connecting..."
                            clientSocket.Connect("myServer IP here", 3234)
                            'Timer2.Start()
                        End If

                    Catch ex As Exception
                        'MsgBox(ex.Message)
                    End Try
                Else
                    If clientSocket.Connected = True Then
                        status = "Online"
                        'Timer2.Start()
                        'btnRegister.Enabled = True
                        'Timer2.Stop()
                        ' btnRegister.Enabled = True
                    Else
                        status = "Offline"
                        clientSocket.Connect("myServer IP Her", 3234)
                        'Timer2.Start()
                    End If
                End If
            Catch ex As Exception

            End Try

        Loop

I don't know where to start. There's so much wrong with the given code such as "myServer IP Her" that I can't tell if your IP plan was even close to being right.

Hide the details at your own peril but as it stands my bet is your system is OK but setup is a PITR. You are making requirements that run of the mill gamers can't do. I'd start a discussion about P2P comms that don't rely on configurations of the router.

Thanks but I didn't get any of what you are saying. The "myServer IP HERE" is where I write my server IP Address.

Since the server IP address and more is not told, I can't see if there's a basic mistake I've seen before. You don't have to tell the full address. Just the first 2 numbers like 192.168.x.x and then I'll know.

192.168.8.xxx

That's a non routable address. So there's your problem. The server IP would be the one you get for the WAN interface.

Since you are on the internet, and your app works for the LAN, you have to put up your server just like you noted, expose it to the internet with either port forwards or the DMZ entry and on the client the server IP would be your internet IP. Not your local IP.

Thanks but can you please enlighten me into details what you are saying. Sorry just that this thing has messed with my head a lot now.

Remember you didn't reveal your internet IP so I'll use something in the example.

Your server behind the router is at 192.168.8.xxx.
The router the server is wired to has it's port forward or DMZ setup to reach 192.168.8.xxx
To connect to the server your server IP is the internet IP the router obtained, which is not 192.168.8.xxx

To connect to the server your server IP is the internet IP the router obtained, which is not 192.168.8.xxx

You mean I will have to assign another IP address different from this? even my gateway uses a similer IP only the last parts is different. My full IP is 192.168.8.100

192.168.8.100 is non-routable and not an internet IP address. The client would not use this as the server IP.

There are a few ISPs that do something strange and your "internet" IP can be 192 or 10 based (non routeable) but I guess this all new to you.

https://www.google.com/search?q=what+is+my+internet+ip+address&ie=utf-8&oe=utf-8 should show your internet IP address. This for most is what the SERVER IP address would be. After that, the router would be configured so your server gets the messages.

commented: Clear enough. Great +5

Thanks now I get you. Thanks and yes this is my first TCP/IP based application.

Mr.M.
Tipping my hand here. While I did write router code in the '90s that doesn't mean I'm the best at explaining it all. Hope you can muddle or muggle through this one.

https://www.google.com/search?q=what+is+my+internet+ip+address&ie=utf-8&oe=utf-8 should show your internet IP address. This for most is what the SERVER IP address would be. After that, the router would be configured so your server gets the messages.

Well now the problem is that the IP address displayed when clicking that link or at http://www.whatismyip.org the server gives me Error 10049. Do I have to keep the server with the local IP address and on the client assign this IP address displayed by the link above or still this will not work? Also I've saw some other articles with similar problem some were recommended to use DynDNS and I've also registered there but the site I used was .org and on my router they is only one option which is for that ending with .com and I've checked it, it costing so as I'm testing I would like to go with the one that I already have which is a free service.

Any help here or should I assign that IP address as Static IP on my computer?

I really don't know what to do here now.

Without commenting on networking skills.... The server is not what I'd touch. The client needs to find this server so whatsmyip is run on the server. And you supply that IP to the client.

Ok thanks will test this out tomorrow and see if it does connect and I will update you. Thanks again, and please bear with me, I'm pretty new to this.

Hi, Well it still doesn't connect and I'm not sure if it me or but it seems as if there is something really off here.

The server is not what I'd touch. The client needs to find this server so whatsmyip is run on the server. And you supply that IP to the client.

If I don't add the IP address on the server listener it will listen to 192.168.8.100 and the client I've issued it the IP address that was displayed by whatismyip.org but these two IP address are not the same, which makes me wonder how will a client route or connect to the server as my Public IP address is something else very different then the local IP address of which my server listens to?

Also the DMZ I've also enabled the IP 192.168.8.100 but still it doesn't connect. What am I missing here because it looks like there is something I'm missing here.

maybe I should also include that I'm connected to the router over wifi connection not with cable.

If client and server are on the same LAN, then the client uses the server LAN IP. This works as you told me in your first post.

If your client is outside the LAN, then you use the external IP and port forward on the router.

FINALLY, if the server is on WiFi some routers do not send packets to the WiFi PC from the WAN. It's a feature of the router's FIREWALL. As a networker I don't expect seasoned networkers to know that one!

Ok on this router under the firewall Switch there was these options:

Enable firewall ---> this was enabled
Enable IP address filter
Disable WAN port ping ---> this was also enabled
Enable domain name filter
Enable MAC filter

I will disable the firewall and see if it connect tomorrow because a person who has helping me with the client side test is now asleep and he is in another province. I'm hoping that it was this router firewall that is blocking the connection.

"Ok on this router under the firewall Switch there was these options:"

I can't be your router/firewall support here. While it looks as if someone was locking down the network, you also will find that these lockdowns can interfere with access to your server.

Maybe you shouldn't be hosting this service?

:-) lol, No I won't be hosting it on this computer, I'm performing a test to ensure that it functions over WAN, once done then will be installed on a server computer which will be hosting this.

And testing is all well and good but to me this reads as if you don't know your own network and gear.

Here's an example where the router with its firewall really sends those that didn't know off the deep end.
"See Page 43: http://www.downloads.netgear.com/files/GDC/DGN2200/DGN2200_UM_3Feb11.pdf

"Your modem router has a firewall that blocks unauthorized access to your wireless network and permits authorized inbound and outbound communications. Authorized communications are established according to inbound and outbound rules. The firewall has the following two default rules. You can create custom rules to further restrict the outbound communications or more widely open the inbound communications:
• Inbound. Block all access from outside except responses to requests from the LAN side.
• Outbound. Allow all access from the LAN side to the outside"

Notice how an inbound access from WiFi is blocked? You'll want to change that.
Page 44 (using the page counter in the PDF viewer) shows the default is BLOCK ALWAYS.

This means features like access to a DLNA, NAS or other server can fail."

You've configured your router to block this, that, ping and must understand what all this does.

-> That's on top of understanding which IP to use in the client for local (LAN) or from the internet.

Thanks I did find the problem to this months ago and the problem was actually with the Internet Package I had. The package didn't have a static Public IP address, the IP was changing now and then and also another problem was that the router didn't issue a computer connecting to it a static IP address the IP addresses of our computers were keep swopping around, this time this IP address is issued to my computer, next time its issued to another computer and I'm issued another IP address. This was caused by not staying connected to the router and when another person comes and connect while you are offline then the IP address you were using will be issued someone else whos connected by that time.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.