路由器后面的服务器程序 [英] Server Program behind a router

查看:124
本文介绍了路由器后面的服务器程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在这里了解很多事情.我不想通读完整的书卷或文章,只是想解决下面提到的情况.另外,我在所见过的论坛中找不到答案.如果可以的话,请直接给我一个简洁的答案.这个问题(我希望)与我使用的编程语言无关.如果这很重要,可以将Visual C ++视为我正在使用的语言.所以这是我的问题.请忍受.

我使用的网络是通过代理连接到Internet的.我使用 http://www.whatismyip.com/ [
到目前为止,我只需要处理一个IP地址和一个IP地址即可.服务器的单个端口(从编程的角度来看).从连接的角度来看,我有两个IP及其两个对应的端口.

我打算制作一个服务器程序,该程序可以接受来自本地LAN外部的连接(最好是TCP).我无法访问路由器.我打算在这里将服务器程序托管在本地计算机中.我想让服务器程序在本地客户端和外部客户端(与我的客户端没有相同外部IP的客户端)之间进行数据传输.外部客户端本身可能具有一个外部IP和一个内部IP. 这可能吗?如何做呢?函数调用的外观如何?请提供一个代码段(如果可能的话).

我在这里的本地计算机中使用了"Ares Galaxy p2p"之类的程序,发现它们可以正常运行.即使他们使用连接管理器执行此操作(我感觉是这样),最终他们仍然能够将LAN外部的远程计算机与本地计算机连接.据我所知,连接管理器程序仅用于获取它尝试连接的Computer1和Computer2的IP地址集.一旦Computer1和Computer2上的程序具有彼此的信息,它们就可以直接连接(在那一刻,一个充当服务器,另一个充当客户端).

就我而言,我声称拥有的信息集是 internal&我的本地计算机的外部IP (具有服务器程序),内部& 尝试连接的外部客户端的外部IP地址和我可以为服务器程序设置的任意端口地址.

由于无法访问路由器,因此有关端口转发"的文章没有帮助.我想通过外部检查(例如从一个网站)来了解局域网外部可用的端口是什么,但是到目前为止,我使用过的所有网站都表明我的端口都已关闭;这些端口必须是代理服务器的端口).无论如何,战神程序正在执行数据传输.

请给我具体的问题答案.我希望这个问题能得到很好的解释(并且可以避免许多常见的背景信息搜寻问题:)).如果上述内容在上下文中似乎不正确,请更正我.我不确定的许多内容都以陈述的形式表达.谢谢.

There are a lot of things I''m trying to understand here. I don''t want to read through entire book volumes or articles, just the possible solution to the condition mentioned below. Also, I couldn''t find the answer in the forums I have seen. Please direct to me a concise answer if available. The question (I hope) is not dependent on the programming language I am using. Visual C++ can be considered as the language I am using if that is important. So here is my question. Please bear with the length.

I use a network in which I am connected to internet through a proxy. This information was confirmed by me using http://www.whatismyip.com/[^_^]. It showed my external IP and the name of the proxy detected. The external IP never seem to change.

I could make a server program which is hosted in a local computer & could accept connections & do data transfer between other local computers within the LAN using corresponding client program. Since, the IPs of the LAN are assigned by a DHCP server, all the local computers end up having different IPs whenever rebooted. To makes things easier, the server program runs on a particular computer & listens to a particular hard-coded port. The client programs have the computer name of that server computer hard-coded into them. They resolve the IP of the server from the computer name & connect to the particular hard-coded port. I guess the port of the client is assigned by the OS in the client computer. The firewall in the local computer asks permission whenever I start the server program & I always allow it to access all public networks. Firewall never asks permission for my client programs & they work alright. In this context, by server program I mean which can "listen to a port and accept incoming connections" & by client program I mean "which tries to connect to a server program at a particular known computer".

So far I had to deal with a single IP address & a single port that of the server (from programming point of view). From the connection point of view, I had two IPs and their two corresponding ports.

I intend to make a server program that can accept connections (preferably TCP) from outside my local LAN. I have no access to the router. I intend to host the server program in a local computer here. I would like to have the server program do data transfer between a local client and an external client (a client who doesn''t have the same external IP as mine). The external client himself might have an external IP and an internal IP. Is this possible? How can it be done? How would the function calls look like? Please provide a code snippet (if possible).

I have used programs like "Ares Galaxy p2p" in the local computers here and seen that they work alright. Even though they do it using a connection manager (I feel so), ultimately they are capable of connecting a remote computer outside my LAN with my local computer. As far as I know, the connection manager program is used only to procure the set of IP addresses of the Computer1 and Computer2 that it is trying to connect. Once the programs at Computer1 and Computer2 has information about each other, they can connect directly (one acting as a server & another as a client for that moment).

In my case, the set of information I claim to have are internal & external IPs of my local computer (which has the server program), internal & external IPs of the client outside who is trying to connect and an arbitrary port address that I can set for the server program.

Articles on "port-forwarding" have not been helpful since I have no access to the router. I would like to know what are the usable ports from outside my LAN through an external checking (like from a website; but so far all the websites I have used show that my ports are all closed; those must be the ports of the proxy sever). Anyways, Ares program is doing the data transfer.

Please give me specific answers to the questions. I hope the problem is well explained (& so many usual background-information-seeking-questions can be avoided :) ). Please correct me if anything stated above seems incorrect to the context.Many of the things which I''m unsure are expressed as statements. Thank You.

推荐答案

Here[^] is an article that describes how Skype and others get around firewalls. Using those techniques should get around your lack of access to the router.

This is unlikely to be the complete solution, but with any luck it will get you started in the right direction.

Another thing that might be worth studying is how ftp passive mode works. Wikipedia is probably a good place to start.

Cheers,
Peter


这篇关于路由器后面的服务器程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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