Exemple #1
0
func main() {
	done := make(chan bool)
	counter := 0
	go server.StartServer(func(conn net.Conn) {
		conn.Write([]byte("Hello\n"))
		conn.Close()
		counter++
		log.Println("Sent back hello", counter)
		if counter >= NumRequests {
			done <- true
		}
	})
	ClientPool = make(chan chan bool)
	for index := 0; index < CreateClients; index++ {
		log.Println("Creating client", index)
		client := NewTestClient(ClientPool)
		client.Run()
	}
	log.Println("Server started")
	for index := 0; index < NumRequests; index++ {
		doReq := <-ClientPool
		doReq <- true
	}
	log.Println("Waiting for requests to finish")
	<-done
	log.Println("All requests finished")
}
Exemple #2
0
func main() {
	server.StartServer(connection)
}