Hochwasser/pixelflut/net.go

31 lines
564 B
Go
Raw Normal View History

package pixelflut
import (
"log"
2020-02-06 01:01:05 +01:00
"net"
)
2020-02-06 01:01:05 +01:00
// @speed: add some performance reporting mechanism on these functions when
// called as goroutines
// bombAddress writes the given message via plain TCP to the given address,
// forever, as fast as possible.
func bombAddress(message []byte, address string) {
conn, err := net.Dial("tcp", address)
if err != nil {
log.Fatal(err)
}
defer conn.Close()
bombConn(message, conn)
2020-02-06 01:01:05 +01:00
}
func bombConn(message []byte, conn net.Conn) {
for {
_, err := conn.Write(message)
if err != nil {
log.Fatal(err)
}
}
}