Can you use TCP or WebSockets through Javascript on Android and iOS devices?

What I'm trying to do is create and establish a connection with the built-in Wi-Fi device (as well as with the arduino board), which has no frills at all. It basically accepts a socket and listens for information and responds.

I fully use PhoneGap to make the application compatible with other devices.

I planned to try and make TCP sockets using a javascript plug-in, however, all the plug-ins that I need require server-side scripts (in this case, this is not possible). I can always install a gateway between Android and iOS devices, but it seems inefficient if I can just create a socket for the browser.

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 that I will be able to create a plug-in for PhoneGap that calls the SocketHandler native code?

Actually, do they already have a plugin that will allow you to use your own TCP sockets through javascript?

I hope my questions make sense. Basically looking for a way to send small consecutive messages over TCP / IP through a web browser on a mobile device.

Does anyone know this?

+4
source share
1 answer

There are several plugins for the PhoneGap network. Three of them:

They should provide you with network sockets that can send TCP requests.

As for WebSockets: WebSockets (hereinafter “WS”) is an application layer protocol such as HTTP or XMPP. You can implement WS using TCP yourself, since WS is on top of TCP.

If Android WebView can send WS requests natively, you should use this instead. WS is nothing more than a protocol that resides on TCP and looks like HTTP. Just use the WebSocket server library, for example ws2py for Python or ws for Node.js. Use only TCP if you need to connect to an existing service that does not understand or accept WebSockets.

+7
source

All Articles