Sending Dpws-Hello, implementation of nativesocket

I’m trying to run a DPWS-service on the Cobra.

As a start i tested the service in the emulator, which runs fine.
After trying to run the service at the cobra, it seems that the hello-discovery messages arent multicasted onto the network.

I did some step-through debugging with the 4.1PK sourcecodes, and came to the following point:


return NativeSocket.sendto(this, buffer, offset, size, (int)socketFlags, m_sendTimeout, address);



the socket is not binded to any LocalEndpoint at this moment, and the remote-endpoint is given as a parameter ‘address’ : / default ws-discovery multicast address.

The emulator handles this situation fine, and i do see my messages multicasted onto the network. (verified with wireshark)
But the cobra apparently doenst since i don’t see any messages appear in wireshark.

Could it be that the nativesocket-implementation has to bind itself when it has no localEP specified, and that the cobra-implementation lacks this requirement?

I’m pretty sure there’s no networkdevice/router blocking the mutlicasts, since i do see discovery-multicast messages from other devices/wsservices in our network.

Are using WiFi or Ethernet?

Oh and i’m running the HelloWorldServer_MF project from the 4.1 samples.

and i’m ammased by your superhuman response-times :wink:

I will forward this to our networking experts…stay tuned!

Please send us an email to ghielec at ghi… with link to this post. We will send you some libraries to try.

email is send :slight_smile:

[Original post removed/edited]

Last night my laptop rebooted for an automatic-update, and visualstudio has been forced to close as a result of it. I’ve got no idea what exactly changed, but the unbinded socket now IS throwing an socketexception, where as it dind’t yesterday.

The SocketException has errorcode 10049:

Cannot assign requested address.
The requested address is not valid in its context. This normally results from an attempt to bind to an address that is not valid for the local computer. This can also result from connect, sendto, WSAConnect, WSAJoinLeaf, or WSASendTo when the remote address or port is not valid for a remote computer (for example, address or port 0).

Not that it brings any new info, since we already thought/knew that it was due the fact that the socket wasn’t binded …

I’m awaiting the test-libraries Mike would send me, but if you could let the nativesocket bind itself in case it isn’t binded already that would be great, since i can’t change the fact that dpws calls Send in an unbinded-state…

thnx so far…

That happened on the device, no exceptions yesterday and now you see them?!

How did rebooting the PC change the behavior of the device!

I’ve got no idea, the HelloWorldMFServer ánd my own project both throw the exception now.
But it doesn’t change much to the problem, dpws still calls the send function while it’s not binded to any local Endpoint. It just returns an exception now where it didn’t yesterday.

The only disadvantage of this is that the whole dpws-startup sequence is terminated by this exception, where it could yesterday carry on and just skip the hello-broadcast …

Can you post more of your code?

I’m using the HelloWorldServer_MF sample project as reference, it seems a bit of a overkill to post all of that code here since everybody has it in the samples folder?

If i could do anything to explain the problem any better/precise i would be happy to, but the problem seems clear; once

[quote]ServerBindingContext ctx = new ServerBindingContext(version);
// Start the device

is called it throws a SocketException because the socket that should broadcast a hello-message multicast is unbinded when called Send() upon.
(this happends in the netmf-dpws binaries)

However, when runned in the emulator, the nativesocket implementation of the emulator seems to be calling the bind() method by itself if necessary, becausy the mutlicast is send…