2022-02-20 11:34:10 +01:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2022-02-20 11:41:41 +01:00
|
|
|
// Attente connexion du FileFrontEnd
|
|
|
|
con, err := listen.Accept()
|
2022-02-20 11:34:10 +01:00
|
|
|
|
2022-02-20 11:41:41 +01:00
|
|
|
if err != nil {
|
|
|
|
fmt.Printf("Error while accepting client : %s\n", err)
|
|
|
|
return
|
|
|
|
} else {
|
2022-02-20 11:34:10 +01:00
|
|
|
|
2022-02-20 11:41:41 +01:00
|
|
|
line, err := bufio.NewReader(con).ReadString('\n')
|
2022-02-20 11:34:10 +01:00
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-02-20 11:41:41 +01:00
|
|
|
fmt.Printf("MESSAGE : %s\n", line)
|
2022-02-20 11:34:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|