.NET套接字和防火墙。 [英] .NET Sockets and the firewall.

查看:88
本文介绍了.NET套接字和防火墙。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一个相当简单的工具,它打开一个套接字并等待请求。没有什么花哨。当我构建并作为工具运行时,我的系统会弹出一个对话框,需要管理员批准。给它这样,应用程序运行处理来自网络的请求。
很棒。


当我将其构建为服务时,它没有收到请求。作为测试,我关闭了防火墙。 关闭防火墙后,它作为一项服务正常运行。所以防火墙阻止了我的服务。


我的问题是,当构建一个允许端口打开的服务时我需要做什么?


我已经通过.NET挖掘并且看不到对此的支持。我发现谷歌搜索的内容已经相当陈旧(比如5年多)。 有人知道正确的解决方案吗?


 

解决方案

Hi Snowopolis,


根据我的知识,我认为不可能直接使用编码或在构建中进行一些更改而不是在Windows 7或Vista中以管理员身份运行您的exe,这总是询问用户他/她是否想要允许打开
指定端口的应用程序。


此限制不是由applpication引起的,而是OS不允许任何应用程序打开或关闭计算机上的端口。


您还可以强制Exe始终以管理员模式运行,只需查看以下链接,了解如何实现它


http://stackoverflow.com/questions/2818179 / how-to-force-my-c-program-to-administrator-as-administrator-on-windows-7


它只是在应用程序清单中添加一行文件


< requestedExecutionLevel level =" requireAdministrator" uiAccess = QUOT假QUOT; />


I've written a fairly simple tool that opens a socket and waits for requests. Nothing fancy. When I build and run as a tool, my system pops up a dialog needing admin approval. Give it such and the apps runs along handling requests from the network. Great.

When I build it as a service it isn't receiving requests. As a test I turned off the firewall. With the firewall off, it's working fine as a service. So the firewall is blocking my service.

My question is, what do I need to do when building as a service that allows the port to be open?

I've dug through .NET and don't see support for this. What little I've found Googling has all been fairly old (like 5+ years).  Anyone know the right solution?

 

解决方案

Hi Snowopolis,

According to my knowledge, I think this is not possible directly using coding or making some changes in build rather in Windows 7 or Vista run your exe as administrator which always asks the user whether he/she wants to allow the application to open the specified port.

This limitation is not caused by applpication rather then it is O.S which don't allow any application to open or close ports on machine.

You can also force the Exe to always run as administrator mode just look at the below link how you can achieve it

http://stackoverflow.com/questions/2818179/how-to-force-my-c-program-to-run-as-administrator-on-windows-7

It is merely adding one line in Application manifest file

<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />


这篇关于.NET套接字和防火墙。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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