How to send UDP multicast packets through Silverlight? - silverlight

I'm trying to find a way to send a udp broadcast packets through a silverlight application. Most of the research i've done lists that this is not possible through silverlight due to the support for sockets being limited to tcp only. But is there some other way to send a broadcast packet for example through javascript or something that the silverlight application can call?

Silverlight 4 supports UDP for multicast.
Articles / Examples
example of using UDP multicast support in Silverlight 4
blog entry from the System.Net Team
Classes
UdpAnySourceMulticastClient
UdpSingleSourceMulticastClient

The only plugins that support UDP client sending is Unity3D or Java. The problem mainly is when you use UDP you also need NAT punchthrough usually. So it is more complex (need a third party facilitator) since typically it is also peer to peer not just client-server.
You might be able to rig something with a proxy with Unity3D or Java but that would be a serious slowdown passing it into silverlight.
Silverlight and Flash only support TCP sockets currently.. Flash 10 does have some support for RTMFP which is UDP based but that is primarily for flash media server integration.
A response on the support of UDP in Silverlight: http://silverlight.net/forums/t/20249.aspx

You'll probably need to create your own custom browser plugin to do that for you.
As far as I know it isn't possible to use UDP with the major browser plugins, Flash, Silverlight etc. TCP is the lowest you get.
Browser based JS does not give programmatic access to UDP or even TCP. That is why you have AJAX, HTTP binding, Comet, XMPP Bosh etc. They try to emulate TCP's features with HTTP...
It appears Flash supports UDP as of Flash 10. I haven't tried it out but it sounds like it is not a low level API, only through RTMFP.
http://www.flashcomguru.com/index.cfm/2008/5/15/player-10-beta-speex-p2p-rtmfp
http://justin.everett-church.com/index.php/2008/05/23/astrop2p/

Flash Player 10.1 supports P2P with Adobe RTMFP and Stratus service. Stratus service is a Beta hosted rendezvous service that aids establishing communications between Flash Player endpoints. Unlike Flash Media Server, Stratus service mainly focuses on network address lookup and NAT traversal services for Flash Player endpoints, instead of supporting media relay, shared objects. This kind of service will also be integrated into next version of FMS.

No there isn't. Most browsers limit you to HTTP or FTP so calling out to Javascript isn't going to help either.

Related

iOS Sockets library listen support

I am finding some conflicting articles, some are old, about CN1 not having Sockets but I see the library com.codename1.io.Socket. I have seen some articles saying it works on Android as well but not iOS. I need the capability to listen on a socket on iOS and was hoping to use an internal library. The shannah/CN1Sockets project doesn't appear to support listening.
From 2014, https://www.codenameone.com/blog/sockets-multiline-trees.html , and lists non iOS support. Any update on this?
Codova/Phonegap does have a few libraries and someone implements Chrome's TCP/UDP API for it as well.
Server sockets are very problematic across platforms as the iOS implementation is radically different from the Android implementation and a bit challenging to implement using the listen paradigm.
It's probably possible to implement server sockets on iOS but because there wasn't much demand and this required some work we chose not to do it. It's also not very useful ans phones move around/change networks. You won't get a stable IP to work against anyway. A better way would be to initiate communication from the client and then communicate back. Notice you won't be able to use a server socket in a background process in iOS anyway as the process will be killed when sent to background!
The only Cordova implementation I found is this: https://github.com/MobileChromeApps/cordova-plugin-chrome-apps-sockets-tcpServer
You can probably use that with native interfaces or just use it as a baseline for a pull request to implement server sockets on iOS but again it's very unlikely that what you are trying to do with server sockets won't work due to iOS limitations.

CAN Communication

How can I implement CAN communication in c# windows application. I have to create an application that communicate to the device. In earlier project I used serial port. What will be the major difference between these two.. Am new to this topic.
You need a CAN controller. I would recommend the PCAN USB from PEAK Systems.
Install the drivers
Download the PCAN API from PEAK System web page. (contains C# wrappers)
Use the API in your application to send and receive CAN frames

Is there any framework to allow P2P communication via phone?

I want to build an app that allow P2P communication(send message, exchange files), I build the app with phonegap, since I want my app cross platform.
I know WebRTC allow real-time communication, but browsers doesn't support it very well. I also found Websocket plugin for phonegap, this satisfied part of my requirement, I can use this send message, but if I use websocket to send files from A to B, I guess all traffic will go through my server, it a pressure for server and I don't want my server carry so much traffic. I can't make a peer to peer connection between A and B.
Is there anyway to make a P2P communication on phone? Any workaround solution is also welcome.
You can do peer to peer connections using Flash or the recent WebRTC. Currently these are the only options you can use to do so, as WebSockets will only connect to a server.
As Flash is not supported by most phones (only Android < 4.0 has support), you can only use WebRTC. But WebRTC is only available on Chrome Beta for now, so you'll still have a cross platform app that will not work in most platforms/devices.
You will have to go through server (WebSockets or HTTP) to increase the number of devices you can cover.
You can use Boost asio sockets to build you own P2P app. but you need to build it for Android NDK and IOS.
Please do take a look at these links before you get into a conclusion
Official "Boost library" Support for Android and iOS?
Limitations to using (Boost) Asio with Android NDK
http://beta.boost.org/development/tests/trunk/developer/summary.html
http://www.codeproject.com/Tips/555070/Boost-vs-OSX-iOS-XCode
Hope it helps
On WebRTC you can use RTCDataChannel, in my experience, on chrome, using this involves writing a lot of code around reliability as the packets arrive out of order or not at all if sent too quickly.
However I think as the WebRTC spec evolves this will improve with implementation.
Use this for generating a RTCDataChannel enabled peerconnection:
var localpeer = new webkitRTCPeerConnection(localConfig,{ 'optional': [{'RtpDataChannels': true }] });

Behind NAT to behind NAT connection

I've come across an interesting problem. Basically I have 2 mobile phones that are both behind NATs. I want to communicate directly between the 2 devices using UDP.
I know if I initiate a connection from the phones to a server then I can push data back down that connection to the phone (ie send it back from the same port that received the message to the same ip and port that it was received from). So I can easily communicate between the 2 devices by connecting both phones to the server. Then sending data to the server and having it re-routed back to the phones. This bypasses any NAT traversal issues I may come up against.
However I would rather just use the server to point the 2 devices at each other and then let them communicate directly. How would I go about doing this? Is it possible without using something like uPnP?
Any help would be much appreicated!
Edit: I found this document http://www.brynosaurus.com/pub/net/p2pnat/ It looks like hairpin translation is what I'm after but it doesn't look to be widely supported. I wonder how good mobile ISP's support for UPnP is?
What you're looking for is UDP hole punching, see e.g. http://en.wikipedia.org/wiki/UDP_hole_punching
The basic idea is simple, you tell each endpoint the ports to use, and they start sending udp packets. The NAT'ing devices will set up a traversal rule when they see the first outgoing packet, and then the next attempt from the other end will match this traversal rule.
You need a mediator server, so the clients can tell where they are. Then one opens a server by uPNP, and the other connects to it.

Push data in Silverlight with Sockets through proxy?

I currently need to make the silverlight 4 in-browser app that can receive push messages from the server. I presume using sockets is the best way, and will also allow a connection between server and client to transfer data and update the page.
But I am worried about firewalls and/or proxy servers.
Is it possible to have push technology, or even sockets at all, whilst behind a proxy that may block everything that isnt on port 80?
Or is it possible to have socket connections on port 80 which would be perfect because it would bypass both proxy and firewall. I am aware that there is a set range of ports available for silverlight, so im meaning a work around.
While on the subject...Would sending a mass block of data from silverlight be faster through sockets, ASP.NET AJAX, or connection to an ASMX web service?
Thanks a ton!
Here's a great article on WCF Polling Duplex (HTTP Long polling or COMET Style) hopes this helps. It's a bit out dated by the content will get you started.
http://tomasz.janczuk.org/2009/08/performance-of-http-polling-duplex.html
You can't connect to TCP socket with port 80 in Silverlight. As you've state there is a limited range of ports (4502-4534) you can connect to and thats it.
Yes firewall will be a concern, just as with other applications such as RDP remote access the firewalls involved between the client and server need to allow connection through one of the allowed port numbers.
Speed of data transfer is largely a function of its encoding. (I don't think AJAX is in the picture here). Ultimately sockets with binary encoding tend to be a bit quicker especially for frequent small transmissions. Whereas HTTP suffers with a bit more overhead however you are much less likely to have a problem with a firewall.
Unless you have a really, really good reason to use sockets use a HTTP based protocol instead. If you abstract out this part of your app reasonably well you could always swap it later.
Have you considered using a WCF PollingDuplex Channel? This allows you to create the "push" from server mechanism whilst sticking with HTTP. In addition much of the plumbing is done for you.

Resources