Skip to content

Commit

Permalink
Fix #23
Browse files Browse the repository at this point in the history
  • Loading branch information
dreamscached committed May 22, 2022
1 parent 0902c57 commit 6d5827b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions ping/net.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@ import (
)

func newTCPConn(host string, port uint16, deadline time.Time) (net.Conn, error) {
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", host, port))
dialer := &net.Dialer{Deadline: deadline}

conn, err := dialer.Dial("tcp", fmt.Sprintf("%s:%d", host, port))
if err != nil {
return nil, err
}

if err = conn.SetDeadline(deadline); err != nil {
return nil, err
}
if err != nil {
return nil, err
}

return conn, nil
}

0 comments on commit 6d5827b

Please sign in to comment.