Skip to content

Instantly share code, notes, and snippets.

@o2gy84
Created April 2, 2020 12:33
Show Gist options
  • Save o2gy84/92c5a1c112c11d7f939ca49295305b13 to your computer and use it in GitHub Desktop.
Save o2gy84/92c5a1c112c11d7f939ca49295305b13 to your computer and use it in GitHub Desktop.
package main
import "net"
import "fmt"
import "bufio"
import "time"
func main() {
ln, _ := net.Listen("tcp", ":8081") fmt.Printf("listening on 8081\n")
conn, _ := ln.Accept()
for {
message, _ := bufio.NewReader(conn).ReadString('\n')
fmt.Print("Message Received:", string(message))
var count = 0 for {
count++
bytes, err := conn.Write([]byte(message + "\n"))
fmt.Printf("count: %d, bytes: %d, err: %v\n", count, bytes, err)
time.Sleep(time.Second*5)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment