views:

117

answers:

1

How can I make a UDP request from a Windows Gadget? This gadget is very, very similar to what I want to make, but I'd like to make a gadget that gets game information from TF2 servers by making a UDP request. I took a look at the code for the afrementioned gadget and I really couldn't make heads or tails of it - I was trained in Java, and mostly on simple console apps.

According to MSDN, UdpClient is supported in JScript, but when I fire up IE8's script debugger it gives me an error whenever I try this bit of code:

UdpClient ud1 = new UdpClient();

The error:

"Expected ';'"

JNEXT might work, but it would essentially destroy the portability of my gadget an become a potential security risk. Script# hasn't been updated for quite some time and apparently does not support the UdpClient class.

Ideas?

A: 

I know this is late but I don't like to see questions with no answers, so... the answer is, you can't... not natively, anyway!

Firstly, UdpClient isn't supported by JScript, it's supported by JScript.NET - the managed code version of JScript. The error you've received is a syntax error because you're specifying a type before a variable declaration, something supported in JScript.NET but not JScript.

Secondly, and to actually answer your question, the only way to work with UDP in a Windows Desktop Gadget is to build an ActiveX control or COM interop assembly that would be instantiated by the gadget. See http://www.codeproject.com/KB/gadgets/GadgetInterop.aspx for more information.

Andy E