Coder Social home page Coder Social logo

Comments (3)

cxong avatar cxong commented on May 24, 2024

The solution C-Dogs SDL uses is described here https://cxong.github.io/2016/01/how-to-write-a-lan-server where the listen port 34219 is only used for server discovery, and the game connection itself is on a random free port. This is to avoid having that port conflict with some other program, and also allow multiple servers on the same machine

I don't know what's the canonical way of solving this, would you need to just add a firewall exception for cdogs-sdl?

from cdogs-sdl.

reinerh avatar reinerh commented on May 24, 2024

Choosing random ports works fine on a LAN, where there are no firewall or other restrictions.
But for accepting connections from WAN/internet, the router (and a maybe firewall on the router) need to be configured to forward the ports to a machine inside the local network. Each time a different random port is chosen, the port needs to be figured out and the router needs to be re-configured with it.

A simple solution could be to pick random ports from a small but known range (e.g. 34220-34300). Such a fixed range can be easily configured in most routers.

Or maybe allow for configuration of the randomly chosen ports. Then the user can decide for themselves what ports to use.

would you need to just add a firewall exception for cdogs-sdl

On the machine itself it would be easy to allow every port of a program like cdogs-sdl, but the router (which is a different device) does not know the ports that cdogs-sdl is using, so it can't automatically forward them.
(There is UPnP for automated asking a router to forward ports to a machine, but using it is discouraged as it has a bunch of security problems.)

from cdogs-sdl.

cxong avatar cxong commented on May 24, 2024

I think it would be best to add a cmd line arg to specify the port to serve; since there is no standard way to specify a range for selecting a random port, we'd have to repeatedly bind() which could be very slow.

from cdogs-sdl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.