Socket.io/node.js on the local network?

I have two machines on the same network, for example, 192.168.1.2 and 192.168.1.3.

192.168.1.2 = server / dev pc

192.168.1.3 = pc client / browser

So, on the / dev pc server, I have a socket.io/http server running on port 82

On the client server, I use chrome as a browser

A web page is hosted on the server, for example

<html>
....
    <script type="text/javascript" src="http://localhost:82/socket.io/socket.io.js"></script>
....
</html>

This is the required resource required for the socket.io client. Thus, the resource is loaded on my / dev pc server, but not on my client PC. Therefore, I try:

<html>
....
    <script type="text/javascript" src="http://192.168.1.2:82/socket.io/socket.io.js"></script>
....
</html>

Now it does not work on any PC. I know what it should be

<script src="http://<uri:port>/socket.io/socket.io.js"></script>

as the socket.io github says, but I only want to test on the local network.

I also looked

<script type="text/javascript" src="http://cdn.socket.io/stable/socket.io.js"></script>

but I am using socket.io 0.8.4, so the above version does not work.

, socket.io, ? , , -, socket.io 0.8.4, ?

. .

+5
4

socket.io,

<script>document.write('<script src="//'+ location.hostname + ':9998/socket.io/socket.io.js">\x3C/script>')</script>

, , 9998 , socket.io .

+2

socket.io

var socket = io.connect();

.

+2

<script type="text/javascript" src="http://localhost:82/socket.io/socket.io.js"></script>

<script src="/socket.io/socket.io.js"></script>

0

:

    <script src="/socket.io/socket.io.js"></script>

:

var socket = io.connect('http://192.168.1.3:82', {'forceNew': true});

!

0

All Articles