WPF C#4.0 tcp/ip套接字发送数据 [英] WPF C# 4.0 tcp/ip Sockets sending data

查看:372
本文介绍了WPF C#4.0 tcp/ip套接字发送数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经构建了程序(hpro),当用户按下该按钮时会检查更新按钮,该按钮将请求发送到服务器程序,然后tcp侦听器在hpro中启动.当服务器程序收到请求时,它开始连接,然后像这样发送:

I have built program (hpro) there is check for updates button when user press, button sends request to server program and then tcp listener is starting in hpro. When server program gets request its starting to connect and then send like this:

scks.Connect(_IPAddr, _Port);
scks.Send(clientData);



当此服务器程序收到这样的请求时,我将获得_IPAddr和_Port:



im getting _IPAddr and _Port when this server program gets request like this :

var parts = _ipPort.Split(':');
 _IPAddr = IPAddress.Parse(parts[0]);
_Port = Convert.ToInt32(parts[1]);




Visual Studio在此行>>>上显示错误scks.Connect(_IPAddr,_Port);无法建立连接.

我使用了另一个端口(999),该端口已打开运行hpro的那台机器,一切都很好

因此,如果端口已打开以进行发送,是否可以将其关闭以进行接收?

有人可以帮我吗?




Visual studio gives error on this line >>> scks.Connect(_IPAddr, _Port); That cannot establish connection.

I used another port(999) which is opened to that machine where hpro is running and everything was fine

So if port is open for send does it possible to be closed for receive?

Can anyone help me?

推荐答案

你好,

您确定端口在防火墙中是打开的吗?
Hello,

Are you sure the port is open in the firewall?


要建立连接:
-您尝试连接的地址必须可见.这是正确的吗? (如果在同一地址上的另一个端口有效,则可能不是问题.)
-服务器必须在您指定的端口上运行.您是否启动了一个服务器,该服务器侦听您要连接的端口?
-防火墙注意事项:该端口必须为客户端计算机上的传出连接打开,并且 必须为在服务器计算机上侦听而打开.在现代操作系统下,通常必须设置例外来允许这种情况.您是否在两台计算机上都打开了端口?
To establish a connection:
- the address you are trying to connect to must be visible. Is it correct? (If another port on the same address works, this is probably not the issue.)
- a server must be running on the port you specify. Did you start a server that listens on the port you are trying to connect to?
- firewall considerations: the port must be open for outgoing connections on the client machine, and it must be open for listening on the server machine. Under a modern OS you typically have to set exceptions to allow this; did you open the port on both machines?


这篇关于WPF C#4.0 tcp/ip套接字发送数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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