Behzad Bahmanyar
Behzad Bahmanyar

Reputation: 6305

Socket programming vs. WebSocket for real-time multiplayer game in Android

I'm working on real-time multiplayer game in Android (java) and I narrowed down the my choices for bidirectional connection to WebSocket and Socket programming

My requirements are:

Base on these requirements, I would like to know which is more suitable.

Thanks.

Upvotes: 2

Views: 1507

Answers (1)

vtortola
vtortola

Reputation: 35965

A WebSocket is a regular TCP socket connection that:

  • Mainly, it is supported in web browsers, so they can be used from Javascript.
  • Starts as a HTTP connection, allowing it to easily cross proxies and firewalls, and make use of HTTP mechanisms like cookies and the Origin HTTP header among others. So for example, a Websocket connection will send the cookies that the browser has for that domain.
  • Uses its own data framing protocol.
  • Uses its own PING/PONG schema.

If you do not need any of those, you may be alright with just a socket.

Upvotes: 2

Related Questions