Improve code a bit

This commit is contained in:
Jan Philipp Timme 2019-05-12 21:08:27 +02:00
parent 64f6b7ad0b
commit bdfd0a9be1
1 changed files with 6 additions and 7 deletions

View File

@ -2,19 +2,18 @@ package main
import (
"bufio"
"fmt"
"net"
"os"
)
func runServer() {
func runServer() error {
serverSocket, err := net.Listen("tcp", "127.0.0.1:7777")
if err != nil {
logger.Errorf("Could not create listening socket: %s\n", err.Error())
os.Exit(1)
} else {
logger.Infof("Now listening for incoming connections.\n")
defer serverSocket.Close()
myError := fmt.Errorf("could not create listening socket: %s", err.Error())
return myError
}
logger.Infof("Now listening for incoming connections.\n")
defer serverSocket.Close()
for {
clientConnection, err := serverSocket.Accept()
if err != nil {