Captain GouLash
Captain GouLash

Reputation: 1287

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

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?

Upvotes: 0

Views: 1756

Answers (1)

mscdex
mscdex

Reputation: 106736

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.

Upvotes: 1

Related Questions