diff --git a/cmd/main.go b/cmd/main.go index 44b7923..8ec3b02 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -5,19 +5,18 @@ import ( ) const ( - MULTICAST_ADDRESS = "226.0.0.1:42500" - MULTICAST_SECOND = 10 + MULTICAST_ADDRESS = "226.66.66.1:42500" + MULTICAST_SECOND = 10 // TODO : Changer en 30 secondes + UNICAST_ADDRESS = "0.0.0.0:58000" ) func main() { println("StorBackEnd started !") - //multicast := network.CreateClientMulticast(MULTICAST_ADDRESS, MULTICAST_SECOND) + multicast := network.CreateClientMulticast(MULTICAST_ADDRESS, MULTICAST_SECOND) + go multicast.Run() - /* go */ - //multicast.Run() - - server := network.ServerUnicast{Network: "tcp", Address: "0.0.0.0:58000"} + server := network.ServerUnicast{Network: "tcp", Address: UNICAST_ADDRESS} server.Run() } diff --git a/pkg/network/ServerUnicast.go b/pkg/network/ServerUnicast.go index 1016b46..3e4c655 100644 --- a/pkg/network/ServerUnicast.go +++ b/pkg/network/ServerUnicast.go @@ -20,23 +20,20 @@ func (server ServerUnicast) Run() { return } - // go serverConsole(&cManager) + // Attente connexion du FileFrontEnd + con, err := listen.Accept() - 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 { - 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) } + fmt.Printf("MESSAGE : %s\n", line) } }