-1

I have a multi-player game that uses Java sockets, the server is a standard Java application and the client is a Java applet that runs in the web-browser.

Now since last Java's update (Java 7 update 51) all applets require code signing, so I would like to move way from the applet and rewrite the client in HTML5.

I've been looking into the socket.io and it seems quite easy, but I can't find any information on how to implement it into my server.

I would like to keep the server in Java, because it will be a lot of work to port it, so is there any libs that I could use on my server to make the communication possible between a java sockets server and a socket.io client, or what is the best approach? do I really need to port the entirely server?

Thanks.

3
  • 1
    A socket is a socket; you don't have to change the server at all. (Unless you're using Java object serialization between your applet and server, in which case you're going to have to refactor your network code on the server side not to do that and use something more suitable like JSON). Commented Jan 19, 2014 at 3:08
  • You are right a socket is a socket but the socket.io doesn't work out of the box with the java ServerSocket you have to implement the Handshake and since the socket.io can make multiple types of connections and you need to handle all of them, that's why I was looking for some lib that could help me with that because I can't find any information on how to create my own Handshake handler in java.
    – Rias
    Commented Jan 19, 2014 at 11:14
  • There's absolutely nothing special about a ServerSocket in java. It talks to the underlying native C libraries on the system and creates exactly the same TCP socket as any other socket in any other language. telnet certainly has no problem connecting to it, nor does your web browser. Commented Jan 19, 2014 at 11:19

1 Answer 1

0

The html5 WebSocket on which socket.io works is not equal to a "normal" C or Java socket. It implements its own protocol over TCP which includes handshakes and other stuff. To port your server you have to use a library maybe this helps you.

For more information on the WebSocket protocol see here.

1
  • Thank you, that helped me understand how the Websockets works, and I found some libs Java-WebSocket for pure Websockets and netty-socketio to use with socket.io
    – Rias
    Commented Jan 20, 2014 at 14:51

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.