Commit 92b61e81 authored by Sushant Mahajan's avatar Sushant Mahajan

client.go

parent 4f54a90d
package main
import (
"bufio"
//"bufio"
"fmt"
"net"
"os"
//"os"
"strconv"
//"time"
)
var die bool
......@@ -26,28 +28,40 @@ func doRead(conn net.Conn) {
func tempmain() {
conn, err := net.Dial("tcp", "localhost:5000")
die = false
go doRead(conn)
//go doRead(conn)
//time.Sleep(time.Second*10)
if err != nil {
fmt.Println("Err:", err)
}
reader := bufio.NewReader(os.Stdin)
for {
if die {
break
for i := 0; i < 100; i++ {
data := make([]byte, 1024)
conn.Write([]byte("set abc" + strconv.Itoa(i) + " 200 10\r\nabcd\nkefgh\r\n"))
//time.Sleep(time.Millisecond)
n, err := conn.Read(data)
//fmt.Println(data[:n], err)
if err == nil {
fmt.Println(string(data[:n]))
}
msg, err := reader.ReadString('\n')
if err != nil {
fmt.Println("Err: ", err)
}
fmt.Println(msg)
buf := []byte(msg)[0 : len(msg)-1]
buf = append(buf, []byte("\r\n")...)
fmt.Println(len(buf))
conn.Write(buf)
}
//reader := bufio.NewReader(os.Stdin)
//for {
// if die {
// break
// }
// msg, err := reader.ReadString('\n')
// if err != nil {
// fmt.Println("Err: ", err)
// }
// fmt.Println(msg)
// buf := []byte(msg)[0 : len(msg)-1]
// buf = append(buf, []byte("\r\n")...)
// fmt.Println(len(buf))
// conn.Write(buf)
//}
conn.Close()
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment