From: Scott Worley Date: Sat, 28 Jul 2012 18:38:53 +0000 (-0700) Subject: Allow port to be specified. Default resonably. X-Git-Url: http://git.scottworley.com/reliable-chat/commitdiff_plain/24a546cf6313bc29de260a356d9e5bdffa67627e?ds=sidebyside Allow port to be specified. Default resonably. --- diff --git a/server/server.go b/server/server.go index 7572447..c47bfaa 100644 --- a/server/server.go +++ b/server/server.go @@ -2,10 +2,14 @@ package main import "container/list" import "encoding/json" +import "flag" import "log" import "net/http" +import "strconv" import "time" +var port = flag.Int("port", 21059, "Port to listen on") + type Message struct { Time time.Time Text string @@ -110,7 +114,7 @@ func start_server(store Store) { store.Add <- &Message{time.Now(), r.FormValue("text")} }) - log.Fatal(http.ListenAndServe(":8080", nil)) + log.Fatal(http.ListenAndServe(":" + strconv.Itoa(*port), nil)) } func main() {