Added TCP_TIMEOUT
Default tcp timeout 3minutes. change to optional in newCLAMDTcpConn function.
This commit is contained in:
8
conn.go
8
conn.go
@@ -35,6 +35,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const CHUNK_SIZE = 1024
|
const CHUNK_SIZE = 1024
|
||||||
|
const TCP_TIMEOUT = time.Second * 2
|
||||||
|
|
||||||
type CLAMDConn struct {
|
type CLAMDConn struct {
|
||||||
net.Conn
|
net.Conn
|
||||||
@@ -111,8 +112,13 @@ func (c *CLAMDConn) readResponse() (chan string, sync.WaitGroup, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func newCLAMDTcpConn(address string) (*CLAMDConn, error) {
|
func newCLAMDTcpConn(address string) (*CLAMDConn, error) {
|
||||||
conn, err := net.Dial("tcp", address)
|
conn, err := net.DialTimeout("tcp", address, TCP_TIMEOUT)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if nerr, isOk := err.(net.Error); isOk && nerr.Timeout() {
|
||||||
|
return nil, nerr
|
||||||
|
}
|
||||||
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user