English 中文(简体)
如何允许远程连接 我的. net 应用程序?
原标题:How to allow remote connections to my .net application?

我正用一个桌面和移动应用程序组件撰写一个应用程序。 桌面应用程序正在以 c# 写入, 我希望能够打开它, 作为移动应用程序的服务器( 类似于 AirVideo 的服务器 ) 。 我如何做到这一点而不要求用户配置防火墙和/ 或路由器?

理想的情况是, 我想在桌面应用程序中自行托管一个休息的 wcf 服务。 我已经试过了, 但防火墙的自动配置不允许远程连接到 wcf 服务, 因为它似乎由系统进程托管 。 是否为这种行为找到解决办法?

编辑:我已经通过使用NATUPnP COM 图书馆(http://pitschoft.com/post/2009/02/05/NET-Framework-Communicate-通过-NAT-Router-via-UPnP.aspx),尽我所能解决了路由器问题。 我仍然需要知道如何允许通过防火墙远程连接到自己托管的WCF服务,而无需对防火墙进行任何手工配置(用户可以立即在程序启动后允许连接)。

问题回答

Set a specific port in your router that is designated to route to your server address,
So if your router real ip is a.b.c.d, you should set up that all communication to a.b.c.d:port# is being routed to your server local address. (a.b.c.d:port# --> serverIP)

此设置可以通过您的路由器配置实现 。

In a situation where you cannot tinker with the router setting/firewall settings:
This means you cannot use ports to listen to incoming connections and can only use outgoing connections. to overcome that you will have to use a 3rd server with real IP-Address which will function as a listener for both sides. Typical scenario can be described as follows:

Client Side - A (Desktop)
Client Side - B (Smartphone)
Server Side - S (Communications Server)

  1. S --> Open port for listening to incoming connections.
  2. A --> Connect to S every x seconds to check if requests to do something are waiting.
  3. B --> Connect to S. (issues a waiting request for A)

这样S就成了 双方通讯的代理





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签