Created
April 2, 2020 12:33
-
-
Save o2gy84/92c5a1c112c11d7f939ca49295305b13 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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