Is there a way to do a tcp connection to an IP with javascript?
<p>Let me give a little background on what I am trying to accomplish.</p>

<p>I have a device(chip and pin Terminal) that has a local IP address, It has been programmed to receive certain data and process it.</p>

<p>example: I send the string <code>"05"</code> in hex <code>"30 35"</code> and the terminal reads that and will restart.</p>

<p>I have tried using <a href="https://github.com/sockjs" rel="nofollow">SockJS-Client</a> as well as the built in <a href="https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API" rel="nofollow">WebSockets</a>.</p>

<p>However using Websockets I notice that the browser is sending:</p>

<pre><code>GET / HTTP/1.1
Host: IP:PORT
Connection: Upgrade
Pragma: no-cache
Cache-Control: no-cache
Upgrade: websocket
Origin: MYIP
Sec-WebSocket-Version: 13
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36
Accept-Encoding: gzip, deflate, sdch
Accept-Language: en-US,en;q=0.8
Sec-WebSocket-Key: A1CeTMFnQCZv4GNZbLFnyQ==
Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits
</code></pre>

<p>When my code looks like this:</p>

<pre><code>var exampleSocket = new WebSocket("ws://IP:PORT");

exampleSocket.send("05");
</code></pre>

<p>If I change the code to this:</p>

<pre><code>var exampleSocket = new WebSocket("wss://IP:PORT");

exampleSocket.send("05");
</code></pre>

<p>I just get 3 tags that are sent: <code>SYN(0x0016) ETX(0x0003) SOH(0x0001)</code></p>

<p>Now I'm not sure if you need to have a WebSocket Sever to be able to interpret the incoming data.</p>

<p>SockJS does the same thing by sending extra information about itself and the broswer:</p>

<pre><code>GET /info?t=1452272641278 HTTP/1.1
Host: IP:PORT
Connection: keep-alive
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36
Origin: MYIP
Accept: */*
Referer: MYIP
Accept-Encoding: gzip, deflate, sdch
Accept-Language: en-US,en;q=0.8
</code></pre>

<p>So I guess my question is. Is there a way to just send exactly what I want? without any extra data?</p>

<p>I have completed this in Objective-C as well as C#, I'm just not sure if javascript can do this?</p>

<p>Please ask if anything is unclear and I will try to clarify.</p>