Try adding a dummy write so that the TCP read fails correctly

This commit is contained in:
Kelvin Ly 2023-05-17 07:07:28 -04:00
parent 13239a6b91
commit 738c52984e
1 changed files with 7 additions and 0 deletions

View File

@ -250,6 +250,13 @@ func InitTcpServer(db *sql.DB, state *ShroomState) {
left = buf
}
_, err := conn.Write([]byte{})
if err != nil {
log.Println("tcp write error: ", err)
_ = conn.Close()
log.Println("disconnected from client")
break
}
num_read, err := conn.Read(left)
left = left[num_read:]