diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..bd52db8 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.0.0 \ No newline at end of file diff --git a/conn.go b/conn.go index df83253..32da3a8 100644 --- a/conn.go +++ b/conn.go @@ -32,9 +32,11 @@ import ( "net" "strings" "sync" + "time" ) const CHUNK_SIZE = 1024 +const TCP_TIMEOUT = time.Second * 2 type CLAMDConn struct { net.Conn @@ -111,8 +113,13 @@ func (c *CLAMDConn) readResponse() (chan string, sync.WaitGroup, 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 nerr, isOk := err.(net.Error); isOk && nerr.Timeout() { + return nil, nerr + } + return nil, err }