的TcpListener:听上的每个地址,包括GPRS IP地址 [英] TcpListener: Listen on every address, including GPRS IP address

查看:235
本文介绍了的TcpListener:听上的每个地址,包括GPRS IP地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个简单的一块旧版软件的使用,我们需要
之间采用TCP / IP通过端口15001.我们需要侦听端口15001
为旧版软件进行连接,然后读取其所送我们。

We have a simple piece of legacy software with which we need to communicate using TCP/IP over port 15001. We need to listen on port 15001 for the legacy software to make a connection and then read whatever it sends us.

我们已经测试了这个解决方案翻过互联网和它工作得很好。
然而,如果我们测试跨GPRS TCP / IP网络同样的解决方案,它没有。

We have tested this solution accross the internet and it works just fine. If however we test the same solution across a GPRS TCP/IP network it does not.

所有的基本知识进行了检查,我们可以ping其它设备GPRS网络
和端口15001是不会被任何防火墙。

All the basics have been checked, we can ping other devices in the GPRS network and port 15001 is not blocked by any firewall.

因此,也许有什么不对我的TcpListener?

So maybe there is something wrong with my TcpListener?

据初始化是这样的:

tcpServer = new TcpListener(IPAddress.Any, TCP_PORT);



我假设它监听系统,
,因为在每一个可用的IPv4启用接口我用IPAddress.Any?

I'm assuming it listens on every available IPv4 enabled interface on the system, because I used IPAddress.Any ?

没有任何人有任何想法的差异可能是什么在两个网络之间? (尽管不应该有任何区别),如果有什么我需要改变我的TcpListener?

Does anybody have any idea what the difference might be between the two networks? (Even though there shouldn't be any difference) and if there is something I need to change to my TcpListener?

推荐答案

您需要指定,而不是IPAddress.Any上你要听的IP地址。这里请参见。当您使用IPAddress.Any,它会自动为你选择的网络接口。要收听某个接口上(在你的情况,GPRS),你必须使用正确的IP在构造

You need to specify the IP address on which you want to listen, instead of IPAddress.Any. See here. When you use IPAddress.Any, it will automatically choose the network interface for you. To listen on a certain interface (in your case, GPRS) you have to use the correct IP in the constructor.

这个帖子对获取每个网卡的IP地址的详细信息。

This post has more information on getting the IP address for each nic.

另外,如果你正在寻找一次对每个IP地址听,你需要为每个NIC的TcpListener。

Also, if you're looking to listen on every IP address at once, you'll need a TcpListener for each nic.

这篇关于的TcpListener:听上的每个地址,包括GPRS IP地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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