What I'm trying to do is create and municate to an embedded wifi device (much like an arduino board) that doesn't have any frills at all. It basically accepts a socket and listens for information and responds.
The plete extent is that I'm using PhoneGap in order to make the application cross device patible.
I had planned to try and make TCP sockets using a javascript plug in of some kind, however all of the plugins i've e across require server side scripts (not possible in this case). I can always put a gateway puter between the android and iOS devices, but that seems inefficient if I can just create a browser socket.
So my question is does anyone know of a javascript plugin that can create TCP sockets without server side scripting?
If not, do you think it would be possible for me to create a plug-in for PhoneGap that makes calls to the native SocketHandler Code?
Actually, do they already have a plug-in that would allow you to use the Native TCP Sockets via javascript?
I hope my questions makes sense. Basically looking for a way to send small serial munications via TCP/IP over a web browser on a mobile device.
Anybody know abou this?
What I'm trying to do is create and municate to an embedded wifi device (much like an arduino board) that doesn't have any frills at all. It basically accepts a socket and listens for information and responds.
The plete extent is that I'm using PhoneGap in order to make the application cross device patible.
I had planned to try and make TCP sockets using a javascript plug in of some kind, however all of the plugins i've e across require server side scripts (not possible in this case). I can always put a gateway puter between the android and iOS devices, but that seems inefficient if I can just create a browser socket.
So my question is does anyone know of a javascript plugin that can create TCP sockets without server side scripting?
If not, do you think it would be possible for me to create a plug-in for PhoneGap that makes calls to the native SocketHandler Code?
Actually, do they already have a plug-in that would allow you to use the Native TCP Sockets via javascript?
I hope my questions makes sense. Basically looking for a way to send small serial munications via TCP/IP over a web browser on a mobile device.
Anybody know abou this?
Share Improve this question edited Aug 14, 2012 at 14:58 Poodimizer asked Aug 13, 2012 at 21:41 PoodimizerPoodimizer 6211 gold badge7 silver badges18 bronze badges 2- https://github./Habel/TCPSockets? But there doesn't seem to be an equivalent iOS version that I can find. – apsillers Commented Aug 14, 2012 at 15:01
- That is awesome! I looked all over for one and couldn't find it. I think I found a plugin that will work with iOS: github./purplecabbage/phonegap-plugins/tree/master/iPhone/…. On a sidenote do you think this kind of socket would be possible using a WebSocket or are those dependent on backend coding to make the connection? – Poodimizer Commented Aug 14, 2012 at 15:40
1 Answer
Reset to default 7There are a few plugins available for PhoneGap networking. Three of them are:
- iOS, Android, WP8: https://github./blocshop/sockets-for-cordova
- Android: https://github./Habel/TCPSockets
- iOS: https://github./purplecabbage/phonegap-plugins/tree/master/iPhone/GapSocket
These should give you network-layer sockets that can send TCP requests.
As for WebSockets: WebSockets (hereafter "WS") are an application-layer protocol, like HTTP or XMPP. You can implement WS using TCP yourself, since WS sits on top of TCP.
If Android's WebView can send WS requests natively, you should use that instead. WS is nothing more than a protocol that sits on TCP and looks kind of like HTTP. Just use a WebSocket server library like ws2py for Python or ws for Node.js. Only use TCP if you need to connect to an existing service that doesn't understand or accept WebSockets.