Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Windows Service won't start (udp listener)

12 views
Skip to first unread message

Snedker

unread,
Jul 26, 2009, 7:55:37 PM7/26/09
to
Hi folks,

If I outcomment the last four lines the service will start.

If I in-comment the line
"int recv = sock.ReceiveFrom(data, ref ep);"
the service will fail starting with error code 3534 (the service
reported no errors). Neither are errors written to the event log.

If I run the same code from a console application, everything works
fine.

The code:

protected override void OnStart(string[] args)
{
IPEndPoint iep = new IPEndPoint(IPAddress.Any, 9050);
sock.Bind(iep);
EndPoint ep = (EndPoint)iep;
byte[] data = new byte[1024];
int recv = sock.ReceiveFrom(data, ref ep);
string stringData = Encoding.ASCII.GetString(data, 0,
recv);
data = new byte[1024];
}

Any ideas why that particular line prevents service from starting?

Regards
Morten Snedker

Ben Voigt [C++ MVP]

unread,
Jul 27, 2009, 6:08:59 PM7/27/09
to

"Snedker" <Morten....@gmail.com> wrote in message
news:91969b26-2164-49ef...@d32g2000yqh.googlegroups.com...


> Hi folks,
>
> If I outcomment the last four lines the service will start.
>
> If I in-comment the line
> "int recv = sock.ReceiveFrom(data, ref ep);"
> the service will fail starting with error code 3534 (the service
> reported no errors). Neither are errors written to the event log.
>
>

> Any ideas why that particular line prevents service from starting?

Yeah, you aren't allowed to use blocking calls from the main thread of a
service, it has to return to the Service Control Manager.

>
> Regards
> Morten Snedker

sloan

unread,
Jul 28, 2009, 9:51:45 AM7/28/09
to

Snedker

unread,
Jul 29, 2009, 3:49:58 PM7/29/09
to
On 28 Jul., 00:08, "Ben Voigt [C++ MVP]" <r...@newsgroups.nospam>
wrote:
> "Snedker" <Morten.Sned...@gmail.com> wrote in message

Yup - that was it. Thanks for your help!

Regards /Snedker

0 new messages