Is HTML5 Socket.IO available in C++? - javascript

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.

Related

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

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.

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.

Delphi server with JavaScript client

Hi I was wondering how one would go about setting up a delphi server that can interact with a javascript client. I am developing a game with this tool : www.scirra.com
It is called construct 2 and it uses javascript. It has a plugin to use socket.io and websockets so either one would be great.
So basicly I want to develop a delphi server that would receive messages from the one javascript client and broadcast it to the other javascript client. If the user wanted to host a game he would run the delphi application and then join the game and wait for other players to join.
To sum up;
(A) Is it possible to use websockets in delphi to communicate with javascript.
(B) if so would someone please make a simple demo.
Thanks for your time
There are some WebSocket client and server implementations available (see WebSocket server implementations for Delphi).
By design, client-side JavaScript (in the browser) can use the WebSocket protocol to communicate with the server. The Delphi WebSocket server implementations then can handle the requests and push data back to the client just like any other WebSocket server library. However, I do not know anything about the code quality or Delphi version compatibility of all these libraries so some additional research is required.
Regarding the Demo: most libraries surely include some demo HTML with JavaScript / WebSocket communication. Simply download it and open it in your favorite text editor ;)
p.s. as I can see socket.io not only supports WebSocket but also long polling so basically you can use any HTTP server library for Delphi to write the server side logic. See:
How can I update HTML pages dynamically with Indy HTTP server using jQuery and "Long Polling"?
How to: update HTML pages dynamically using jQuery and “Long Polling”

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 there any javascript ssh client?

I mean pure javascript client that uses HTML5 sockets and doesn't need to be installed, just open single js file in browser. Is it possible to write such client at all?
No.
JavaScript in the browser does not have raw TCP/IP socket support.
It would be possible to create an ssh client using some server-side technology to proxy the connection, and then do the client using JS. But of course for this you would require a server (like node or whatever)
You couldn't do it directly with Web Sockets, as they're (very deliberately) not a general raw socket capability. You would have to have a server-side proxy to forward keystrokes to the target ssh server.
Existing JS SSH implementations (WebShell, AnyTerm) are using XMLHttpRequest to transport data from the client to the proxy server. You could in theory improve their responsiveness by altering them to use WebSocket instead where available, but it's not really widespread yet. Given the number of incompatible changes that have already happened to the specification over its life, many are likely to be waiting for the ‘final’ version.

Categories