Connecting a web client to a c++ server with TCP

1.7k views Asked by At

i wrote a simple C++ Server which is waiting for clients.

I want users to be able to connect to this client by opening a webpage without installing anything. So the only thing that comes to my mind is using Javascript. Since the server needs to react in realtime later on ( performance is an issue ) sending data with POST/GET is not wanted.

Is this possible with Node.js or Socket.io ? I am trying to find a good example but i only find node.js servers. And when i open a socket with

  var socket = io.connect('localhost:25003');

it is sending weird data.

Does anyone have a simple example with a javascript client that can connect to anything and send raw data?

1

There are 1 answers

3
mscdex On

You cannot do plain TCP from browsers (unless you're writing a browser addon/extension or using something like a Java applet or a Flash bridge possibly). Socket.IO always uses HTTP. However those HTTP connections can then be upgraded to WebSockets or other protocols, depending on what the browser and/or Internet connection supports.

The "weird data" you're seeing is probably an HTTP message.