在互联网上(而不是LAN)Android的TCP通信。 [英] Android TCP communication over the internet(not LAN).

查看:183
本文介绍了在互联网上(而不是LAN)Android的TCP通信。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建一个应用程序使用,通过TCP套接字国际互联网建立了两款Android 移动之间的通信。所以,我主要是使用两个移动的IP地址与我看中的应用程序端口号。

I'm creating an app to establish communication between two android mobiles through the internet using TCP sockets. So, I'll primarily be using ip addresses of the two mobiles with my fancy app port no.

这可能吗?要创建自定义的TCP端口和局域网通讯在互联网上什么样的?

到目前为止,我能够在一个局域网内两个仿真之间成功通信。但它不可能做thorugh互联网相同的emultors COS通常主机是路由器,只允许数据端口后面的情况下, 8080 80 我不知道。当然也有端口转发,可以做的,但我不想弄脏这一点。结果
所以,结果
是否在LAN保证仿真器连接移动连接在互联网上?手机直接网连接的情况下,COS 只有一个IP地址(没有私人和外部IP),并没有路由器吧的trafffic。

So far i'm able to successfully communicate between two emulators in a LAN . But it's not possible to do the same thorugh the internet in case of emultors cos usually the host machine is behind a router that allows only data to the port 8080 or 80 i'm not sure. Of course there are port forwarding that can be done, but i don't wanna get dirty with that.
so,
Does emulator connection in LAN guarantee mobile connection in the internet? cos in case of mobile with direct net connectivity there is only single ip address(no private and external ip) and no router to bar the trafffic.

推荐答案

你听说过打洞技术。阅读关于这一点 - 也许这将是有益的链接这是Skype的工作原理我think.The技术。需要在通信另一节点 - 它是由两个客户端访问的服务器,并且这有助于使两个客户即使客户端中的一个是NAT后面之间的直接连接。

Have You heard about hole punching technique. Read about this - maybe it will be helpfull.link This is how skype works I think.The technique requires yet another node in communication - a server which is accessible by both clients, and which helps to make direct connections between two clients even if one of the client is behind a NAT.

这篇关于在互联网上(而不是LAN)Android的TCP通信。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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