从Windows服务接收多播 [英] Receiving Multicasts from a Windows Service
问题描述
我对创建一个可以侦听多播流的Windows服务(VB.NET)感到困惑.我已经创建了该服务,并且还创建了具有相同Sub的控制台应用程序.控制台正常工作;但是该服务将进入Receive方法,并且永远不会越过它,但是并没有停止. (我已经在控制台的前后放置了Console.WriteLines来验证它是否正在接收.)
我知道Windows服务不允许(至少不鼓励)与桌面进行交互. Windows Service是否有某些功能可以阻止他人收听多播广播?
该服务与控制台版本一样,都在Domain Admin帐户下运行.
该服务通过Visual Studio(2008)中的安装项目进行安装.
数据一直在不断流动-大约每秒50-100条记录.
这是我的Sub-再次作为控制台应用程序工作,作为服务停滞:
I am baffled in my attempt to create a Windows service (VB.NET) that can listen to a multicast stream. I have created the service, and have also created a console app with the identical Sub. The console works; but the service gets to the Receive method and never moves past it, but has not stopped. (I''ve put Console.WriteLines before and after to verify that it''s waiting at the Receive.)
I know Windows Services don''t allow (or discourage, at least) interacting with the desktop. Is there something about a Windows Service that prevents one from listening to a multicast broadcast?
The service is running under a Domain Admin account, as is the console version.
The service is being installed through a setup project in Visual Studio (2008).
There is a constant flow of data -- in the neighborhood of 50-100 records per second.
Here is my Sub -- again, works as a console app, stalls as a service:
Private Shared Sub BeginListen(ByVal evt As EventLog)
Dim bteReceiveData() As Byte
Dim strReceiveData As String
GroupIP = IPAddress.Parse("230.0.0.0")
GrpEP = New IPEndPoint(GroupIP, 12345)
ListenUdp = New UdpClient(12345)
ListenUdp.JoinMulticastGroup(GroupIP)
For i As Integer = 1 To 10
evt.WriteEntry("Inside the Receive loop...initiating Receive...")
bteReceiveData = ListenUdp.Receive(GrpEP) '<-- waits here forever
strReceiveData = Encoding.ASCII.GetString(bteReceiveData, 0, _
bteReceiveData.Length - 1)
Next
ListenUdp.Close()
End Sub
在一个多月的时间里,我一直在努力/摸索,并尝试使用不同的技术进行多个测试项目.不可避免地,控制台或Windowsform应用程序可以工作,但服务版本却不能.
I''ve been scratching/pounding my head on this for the better part of a month and have tried multiple test projects using different techniques. Inevitably, a console or windowsform app works, but the service version doesn''t.
Any help will be HUGELY appreciated!
推荐答案
防火墙怎么样? -如果您已激活Windows防火墙.您必须明确地允许"您的程序/服务以在UDP端口上接收.
What about firewall ? - If you have Windows Firewall activated. You have to explicitly "Allow" your program/service to receive on UDP port.
这篇关于从Windows服务接收多播的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!