September 2017
Intermediate to advanced
466 pages
9h 33m
English
The Unix socket server will act as an Echo server, which means that it will send the received message back to the client. The name of the program will be socketServer.go and it will be presented to you in four parts.
The first part of socketServer.go is the following:
package main import ( "fmt" "net" "os" )
The second part of the Unix socket server is the following:
func echoServer(c net.Conn) {
for {
buf := make([]byte, 1024)
nr, err := c.Read(buf)
if err != nil {
return
}
data := buf[0:nr]
fmt.Printf("->: %v\n", string(data))
_, err = c.Write(data)
if err != nil {
fmt.Println(err)
}
}
}
This is where the function that serves incoming connections is implemented.
The third portion of the program has the following Go ...
Read now
Unlock full access