Skip to content

Commit

Permalink
Make the server port configurable
Browse files Browse the repository at this point in the history
This enables people to run the server on machines where port 2000 is already in use.

Resolves #2
  • Loading branch information
mulbc committed Apr 9, 2020
1 parent 473fb9f commit 23f50c8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ func init() {
rand.Seed(time.Now().UnixNano())

flag.StringVar(&configFileLocation, "c", "", "Config file describing test run")
flag.IntVar(&serverPort, "p", 2000, "Port on which the server will be available for clients. Default: 2000")
flag.BoolVar(&debug, "d", false, "enable debug log output")
flag.BoolVar(&trace, "t", false, "enable trace log output")
flag.Parse()
Expand All @@ -40,6 +41,7 @@ func init() {
}

var configFileLocation string
var serverPort int
var readyWorkers chan *net.Conn
var debug, trace bool

Expand All @@ -65,7 +67,7 @@ func main() {

// Listen on TCP port 2000 on all available unicast and
// anycast IP addresses of the local system.
l, err := net.Listen("tcp", ":2000")
l, err := net.Listen("tcp", fmt.Sprintf(":%d", serverPort))
if err != nil {
log.WithError(err).Fatal("Could not open port!")
}
Expand Down

0 comments on commit 23f50c8

Please sign in to comment.