This commit is contained in:
Zack Scholl 2018-09-26 09:55:14 -07:00
parent 4e3138e099
commit 267056b3fd
1 changed files with 6 additions and 7 deletions

View File

@ -1,7 +1,6 @@
package tcp
import (
"bufio"
"net"
"sync"
"time"
@ -129,12 +128,12 @@ func clientCommuncation(port string, c *comm.Comm) (err error) {
// Read()s from the socket to the channel.
func chanFromConn(conn net.Conn) chan []byte {
c := make(chan []byte)
reader := bufio.NewReader(conn)
// reader := bufio.NewReader(conn)
go func() {
for {
b := make([]byte, models.TCP_BUFFER_SIZE)
n, err := reader.Read(b)
n, err := conn.Read(b)
if n > 0 {
// c <- b[:n]
res := make([]byte, n)
@ -158,16 +157,16 @@ func pipe(conn1 net.Conn, conn2 net.Conn) {
chan1 := chanFromConn(conn1)
// chan2 := chanFromConn(conn2)
// writer1 := bufio.NewWriter(conn1)
writer2 := bufio.NewWriter(conn2)
// writer2 := bufio.NewWriter(conn2)
for {
b1 := <-chan1
if b1 == nil {
return
}
// conn2.Write(b1)
writer2.Write(b1)
writer2.Flush()
conn2.Write(b1)
// writer2.Write(b1)
// writer2.Flush()
// case b2 := <-chan2:
// if b2 == nil {