Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8196723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:34:43+00:00 2026-06-07T05:34:43+00:00

I am building a real-time multi-player browser-based game using node.js. At the moment I

  • 0

I am building a real-time multi-player browser-based game using node.js. At the moment I have the client send user input to the game logic server via socket.io and a snapshot of the game world sent back to the client for rendering.

Below is a simplified version of the code. Is it possible to use UDP to send data from the browser-based client to the server and vice-versa? I know Node.js has a UDP module but I am unsure how to implement it in this way.

Any help would be appreciated. Thank you.

Server:

var server = http.createServer(handler).listen(8888);
var iosocket = io.listen(server);

// request/response handler
function handler(req, res){

    ...
}

iosocket.sockets.on('connection', function(socket){
    console.log("[x] Socket listener started");

    socket.on('msg', function(data){
        console.log( " [-] incoming message);
    });
});

...

iosocket.sockets.emit("message", msg);

Client:

<!DOCTYPE html>
<html>
    <head>
        <title>Test</title>
        <script type="text/javascript" src="/socket.io/socket.io.js"></script>
        <script type="text/javascript">
            socket.on('connect', function(){
             console.log("connected to server");
            });

            socket.on('message', function(message){
            console.log('received message');
            });

        </script>
    </head>

    <body>
        <canvas id='canvas' width="400" height="400">Canvas</canvas>
    </body>

</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T05:34:44+00:00Added an answer on June 7, 2026 at 5:34 am

    Generally, browsers do not support UDP connections. Specifically, some browsers do. Google Chrome has a socket api:

    http://developer.chrome.com/trunk/apps/socket.html

    [2012/10/29 Edited as socket is no longer experimental – PhilH]

    You could possibly also use socket APIs from the native client interfaces as well (not sure, only guessing).

    If you’re going try to do anything real-time on browsers in the near future, Websockets is probably your best bet, but those are TCP only.

    Regarding your comments on UDP versus TCP speed, UDP will always be faster. TCP offers ordering and delivery guarantees (this means possible retries and holding other packets back until a lost packet finally arrives at its destination), while UDP only promises to send it once, not caring what happens with it afterwards. UDP will only send it’s packet once and you need to figure out whether it got lost. When/if you receive lots of UDP packets, if order matters, you need to encode this in your data payload to be able to figure it out.

    In general, UDP will be great for packets where missing a few usually do not matter and where only the latest packet really matters. A game may typically use a TCP stream where ordering and guaranteed delivery matters (the important stuff), and UDP streams for object movements etc (where only the latest position really matters, and if one update got lost it does not matter as long as each package contain the full position [instead of a delta where all packets matter]).

    For your own game, I suggest implementing it on TCP first, and then when you have some more experience, you can try move the time critical stuff (where order and lost packets matter less) into separate UDP streams. There are many projects that have failed because people started with UDP first, and then tried bolting on ordering and delivery guarantees on top of it, effectively trying to reimplement TCP. Which is why doing it the other way around makes more sense.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm building a real time game, mostly chat based, and I need to have
I'm currently building a real-time betting engine using redis / thin / sinatra. A
I'm working on a simple 2D Real time strategy game using XNA. Right now
I'm building a simple real time chat using Juggernaut, Redis, SQLite and Rails 3.1
I am building a web application that has a real-time feed (similar to Facebook's
I'm building a community-based site in Rails for the members of a real-world organization.
I am building a real-time app & am wondering if I should bother moving
I'm building a real-time web application As far as I know, the most popular
I am building a real-time reservation system and would like to allow users to
I was able to setup nginx as a message server for building a real-time

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.