mirror of
https://github.com/fatedier/frp.git
synced 2025-08-01 19:49:03 +00:00
utils/conn: fix a socket error in windows
This commit is contained in:
@@ -46,7 +46,7 @@ Options:
|
||||
-L log_file set output log file, including console
|
||||
--log-level=<log_level> set log level: debug, info, warn, error
|
||||
--addr=<bind_addr> listen addr for client, example: 0.0.0.0:7000
|
||||
--reload reload ini file and configures in common section won't be changed
|
||||
--reload reload ini file and configures in common section won't be changed
|
||||
-h --help show this screen
|
||||
-v --version show version
|
||||
`
|
||||
|
@@ -19,6 +19,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"net"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@@ -129,10 +130,13 @@ func (c *Conn) GetLocalAddr() (addr string) {
|
||||
|
||||
func (c *Conn) ReadLine() (buff string, err error) {
|
||||
buff, err = c.Reader.ReadString('\n')
|
||||
if err == io.EOF {
|
||||
c.mutex.Lock()
|
||||
c.closeFlag = true
|
||||
c.mutex.Unlock()
|
||||
if err != nil {
|
||||
// wsarecv error in windows means connection closed
|
||||
if err == io.EOF || strings.Contains(err.Error(), "wsarecv: An existing connection was forcibly closed") {
|
||||
c.mutex.Lock()
|
||||
c.closeFlag = true
|
||||
c.mutex.Unlock()
|
||||
}
|
||||
}
|
||||
return buff, err
|
||||
}
|
||||
|
Reference in New Issue
Block a user