mirror of
https://github.com/EchoVault/SugarDB.git
synced 2025-10-15 04:20:57 +08:00
Send RESP encoded message with double quotes and escaped delimiters to server
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"crypto/tls"
|
||||
"encoding/json"
|
||||
"flag"
|
||||
@@ -29,6 +30,22 @@ type Server struct {
|
||||
config Config
|
||||
}
|
||||
|
||||
func (server *Server) hanndleConnection(conn net.Conn) {
|
||||
rw := bufio.NewReadWriter(bufio.NewReader(conn), bufio.NewWriter(conn))
|
||||
sw := bufio.NewWriter(os.Stdout)
|
||||
|
||||
for {
|
||||
l, _, err := rw.ReadLine()
|
||||
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
sw.Write(l)
|
||||
sw.Flush()
|
||||
}
|
||||
}
|
||||
|
||||
func (server *Server) StartTCP() {
|
||||
conf := server.config
|
||||
var listener net.Listener
|
||||
@@ -69,7 +86,7 @@ func (server *Server) StartTCP() {
|
||||
}
|
||||
|
||||
// Read loop for connection
|
||||
conn.Write([]byte("Hello, Client!\n"))
|
||||
go server.hanndleConnection(conn)
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user