Is it possible to use socket.io without node.js? - javascript

The title pretty muchs sums it up... I am wondering if there is a way to use socket.io without node.js

socket.io is a library that connects a browser web pages to some server somewhere. There MUST be a socket.io server somewhere that does what you want that you can connect to.
That socket.io server does not have to be written using node.js. There is socket.io support for other languages or environments. The protocol and data format is fully documented so implementations can be written for any environment.
For example, here's a socket.io server implementation in C++.
You can look on github for various server implementations: https://github.com/search?q=socket.io+server.

Related

Why in socket io they having set of script lines in html page?

I am trying to develop a flutter chat app using nodejs and socketio.i'm just getting started with the socketio i have surf several examples in which every front end or client side having a set of socketio script. Can i develop my code purely server side? so that i can integrate with any type of front end.
You can do that. Socket.io is a web socket implementation in node js. It enables real-time, bidirectional and event-based communication between client and server.
Server and client can send and receive the events. If you don't want write any script in client side then you don't have any use of sockets.
Edit:
socket.io given nice example for chat application with explanation. https://socket.io/get-started/chat/
Socket.io has two distinct parts - the server and the client. The docs make this clear. There is nothing preventing you from just writing the server part, and leaving the client implementation out of the equation, for someone else to implement.
Although the main point of Socket.io is to implement the WebSocket protocol, it does so by wrapping it in its own interface, so to speak. So a socket.io server can only talk to socket.io clients, not clients that implement WebSocket in other ways. That being said, there are socket.io client libraries for pretty much every major language out there:
Javascript (main client)
Java
C++
Dart/Flutter
You also asked about React and Angular, but both of those are web front-ends, so there should be no reason why they can't use the standard Javascript client library with those frameworks.

Communication between client side javascript and C++ socket server

I would like to communicate between my browser on the client PC and a C++ socket server running on an another PC.
I researched online pretty much enough. I came across socket.io, HTML5 Websockets.
Though I am not sure about socket.io, websockets require a server that supports websockets. The pure old C++ socket server does not. Changing the server side is not an option. Is there anything else I can do with websockets?
Using socket.io, can I achieve the goal without installing an interpreter like nodejs on the server side? Any additional introduction of Javascript/Jquery library on the client side is affordable.
Or is there any other approach I can use?
Thank you.
C++ sockets and websockets are quite different things, having "socket" in their names doesn't mean they operate the same. Websockets protocol is RFC6455. There're several C++ libraries for implementing websocket support, if you can't use any type of web server.

how to imelement node.js WebSocket support?

i read that node.js can fully worked with WebSocket client.
my question is how to support WebSocket api in my node.js server side?
do i need to install something to support that, or just imepements build-in functions?
You can use socket.io, it has both the library for client side and server side (node.js)
Another good one is primus, which wraps up a few different websocket libraries. It is active, and has good documentation for use.
Note: Primus does not, and will not, support socket.io v1.0 or greater So if you must have what socket.io is doing, be aware of your choice.
socket.io is the most straight forward way to implement web sockets in your node app, handling both server-side (as an npm module) and client-side (a script that can be served from your server) features.
http://socket.io/

Socket reading and writing from a web browser app

There is a server I need to talk to that publishes a protocol over TCP/IP for querying data from a database and listening on a socket to receive notifications when data is updated. The sever guys provide a Java API which uses this TCP protocol. This means I could easily write a Swing App to talk to this server.
I would like a browser based solution. As the protocol is known to me, could I do this in JavaScript? My app will have to display the data in a table. I have heard of Web Sockets but I'm not sure if it will allow this two way communication. Is it feasible? Is there a better way that is cross platform and will work in most browsers? Should I be considering a Java Swing based solution that runs inside a browser?
EDIT: What about changing the code in my C++ server to add an additional interface that my Javascript code can communicate directly with it?
The WebSocket protocol differs from TCP/IP sockets. You will have to write something to link them together.
You can do this perfectly well in JavaScript: use Node.js. There's enough tutorials to be found on the subject. The best way to link it to your in-browser JS is through Socket.IO.
Create a Node.js server that connects to the api
Make the server talk to your web app
Use it :)
This will work cross-platform and cross-browser (Socket.IO can use/emulate websockets even on IE6(!!)). You'll have to run a server-app (the Node.js app) though.
My personal opinion is that if you want a web/browser based solution, you should use native technology, and not Java.
Hope this helps :)

Is HTML5 Socket.IO available in C++?

I have a server that creates a websocket. I'm using HTML5, Javascript and JQuery on the client side.
My fellow-student who works on the project uses RFID technology to scan a tag. Then he needs to send me those data from his app via the socket.
Is that possible with his preferred language C++? And how does he need to do that?
There are some websocket implementations for C++ available. See http://en.wikipedia.org/wiki/Comparison_of_WebSocket_implementations Unfortunately I don't have experience with any of them.
When none of these libraries works out for you, I would not recommend that you create your own implementation of WebSocket. It's not a very simple protocol (I know what I am talking about - I wrote a websocket server in Java) and it only makes sense when the client is a web browser. When the client is able to use pure TCP/IP sockets, like a client written in C++, there is no reason to add WebSocket as another layer of indirection.
So you should rather implement an alternative network handler on your server which listens to a normal non-web socket. That would be a lot easier and also reduce protocol overhead and CPU load on client and server.

Categories