StoreBackEnd/pkg/network/ServerUnicast.go

43 lines
622 B
Go
Raw Normal View History

package network
import (
"bufio"
"fmt"
"net"
)
type ServerUnicast struct {
Network string
Address string
}
func (server ServerUnicast) Run() {
listen, err := net.Listen(server.Network, server.Address) // "tcp", "0.0.0.0:58000"
if err != nil {
fmt.Printf("Can't start server : %s\n", err)
return
}
// go serverConsole(&cManager)
for {
con, err := listen.Accept()
if err != nil {
fmt.Printf("Error while accepting client : %s\n", err)
return
} else {
line, err := bufio.NewReader(con).ReadString('\n')
if err != nil {
return
}
fmt.Printf("MESSAGE : %s\n", line)
}
}
}