Improve code a bit
This commit is contained in:
parent
64f6b7ad0b
commit
bdfd0a9be1
11
socket.go
11
socket.go
|
@ -2,19 +2,18 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func runServer() {
|
func runServer() error {
|
||||||
serverSocket, err := net.Listen("tcp", "127.0.0.1:7777")
|
serverSocket, err := net.Listen("tcp", "127.0.0.1:7777")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Errorf("Could not create listening socket: %s\n", err.Error())
|
myError := fmt.Errorf("could not create listening socket: %s", err.Error())
|
||||||
os.Exit(1)
|
return myError
|
||||||
} else {
|
}
|
||||||
logger.Infof("Now listening for incoming connections.\n")
|
logger.Infof("Now listening for incoming connections.\n")
|
||||||
defer serverSocket.Close()
|
defer serverSocket.Close()
|
||||||
}
|
|
||||||
for {
|
for {
|
||||||
clientConnection, err := serverSocket.Accept()
|
clientConnection, err := serverSocket.Accept()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue