Skip to content

Commit

Permalink
setlinger & close EOF tcp conn
Browse files Browse the repository at this point in the history
  • Loading branch information
bufrr authored and yilunzhang committed Jul 13, 2023
1 parent af3d7e0 commit e4bbb51
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ func (te *TunaEntry) listenTCP(ip net.IP, ports []uint32) ([]uint32, error) {
for {
conn, err := listener.Accept()
if c, ok := conn.(*net.TCPConn); ok {
err := c.SetLinger(0)
err := c.SetLinger(5)
if err != nil {
log.Println("Couldn't set linger:", err)
continue
Expand Down Expand Up @@ -704,7 +704,7 @@ func StartReverse(config *EntryConfiguration, wallet *nkn.Wallet) error {
for {
tcpConn, err := listener.Accept()
if c, ok := tcpConn.(*net.TCPConn); ok {
err := c.SetLinger(0)
err := c.SetLinger(5)
if err != nil {
log.Println("Couldn't set linger:", err)
continue
Expand Down Expand Up @@ -851,6 +851,7 @@ func StartReverse(config *EntryConfiguration, wallet *nkn.Wallet) error {
return nil
}()
if err != nil {
tcpConn.Close()
log.Println(err)
}
}()
Expand Down

0 comments on commit e4bbb51

Please sign in to comment.