Created
December 19, 2016 08:56
-
-
Save yanzay/05ed6f198c7e0e76eb940e1d770ee0bf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func startServer() { | |
// compose server address from host and port | |
addr := fmt.Sprintf("%s:%d", *host, *port) | |
// launch TCP server | |
listener, err := net.Listen("tcp", addr) | |
if err != nil { | |
// if we can't launch server for some reason, | |
// we can't do anything about it, just panic! | |
panic(err) | |
} | |
log.Printf("Listening for connections on %s", listener.Addr().String()) | |
for { | |
conn, err := listener.Accept() | |
if err != nil { | |
log.Printf("Error accepting connection from client: %s", err) | |
} else { | |
go processClient(conn) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment