C#我无法让客户端连接到我自己的服务器 [英] C# I can't get my client connect to my own server

查看:65
本文介绍了C#我无法让客户端连接到我自己的服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好!

我自己的程序有问题.

服务器的来源:

Hello!

I have a problem with my own program.

Source for server:

mainServer.ServerBindIPAdress = "my ip address";
            mainServer.ServerBindPort = 1897;



客户来源:



Source for client:

mainClient.Connect("my ip adress", "1897", false);



现在,当我尝试连接时,只会抛出一个异常,表明服务器无法及时响应.

我在路由器中打开了1897端口.图片: http://img696.imageshack.us/img696/1992/portok.png [ ^ ]

操作系统:windows 7
使用的程序:Microsoft Visual Studio C#2008

PS .:在网络上,它运行良好,在localhost上也是如此.



Now when I try to connect it''s just throw an exception that the server couldn''t respond in time.

I have opened the 1897 port in my router. Pics:http://img696.imageshack.us/img696/1992/portok.png[^]

OS:windows 7
used program:Microsoft Visual studio c# 2008

PS.:On network it works perfectly, and so on localhost.

推荐答案

如果我正确,则希望您的客户端软件通过路由器连接到服务器软件.从您的网络之外?

如果是这种情况,则需要客户端连接到服务器端外部ip地址(您可以在此处获取 http://www.whatismyip.com / [ ^ ]),则必须从以下位置转发端口路由器连接到您的计算机.
If i got this right you want your client software to connect to your server software through your router from outside of your network?

If that is the case you need the client to connect to your server side external ip adress(you can get it here http://www.whatismyip.com/[^]), then you have to forward the port from the router to your computer.


这篇关于C#我无法让客户端连接到我自己的服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆