最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

TCP or WebSockets calls through Javascript on Android and iOS devices possible? - Stack Overflow

programmeradmin0浏览0评论

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
Add a ment  | 

1 Answer 1

Reset to default 7

There 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.

发布评论

评论列表(0)

  1. 暂无评论