mirror of
https://github.com/jixishi/SerialTerminalForWindowsTerminal.git
synced 2026-06-16 00:52:44 +00:00
去除TCP服务端连接
This commit is contained in:
@@ -24,7 +24,6 @@ type FoeWardMode int
|
||||
|
||||
const (
|
||||
NOT FoeWardMode = iota
|
||||
TCPS
|
||||
TCPC
|
||||
UDPC
|
||||
)
|
||||
@@ -43,41 +42,8 @@ func setForWardClient() (conn net.Conn) {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
default:
|
||||
panic("未知模式设置")
|
||||
}
|
||||
return conn
|
||||
}
|
||||
func setForWardServer() {
|
||||
switch FoeWardMode(config.forWard) {
|
||||
case TCPS:
|
||||
listen, err := net.Listen("tcp", config.address)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
for {
|
||||
conn, err := listen.Accept() // 监听客户端的连接请求
|
||||
if err != nil {
|
||||
log.Println("Accept() failed, err: ", err)
|
||||
continue
|
||||
}
|
||||
go process(conn) // 启动一个goroutine来处理客户端的连接请求
|
||||
}
|
||||
default:
|
||||
panic("未知模式设置")
|
||||
}
|
||||
}
|
||||
func process(conn net.Conn) {
|
||||
defer conn.Close() // 关闭连接
|
||||
//reader := bufio.NewReader(serialPort)
|
||||
outs = append(outs, conn)
|
||||
defer func() {
|
||||
for i, w := range outs {
|
||||
if w == conn {
|
||||
outs = append(outs[:i], outs[i+1:]...)
|
||||
}
|
||||
}
|
||||
}()
|
||||
input(conn)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user