From 31a0ee37ab35244b594bd84fe740fadfda847a9f Mon Sep 17 00:00:00 2001 From: Peter Date: Tue, 19 May 2015 23:53:01 +0100 Subject: [PATCH] Changed net.Dial to net.DialTimeout to allow adding a reasonable timeout. Also fixed a small typo --- client.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/client.go b/client.go index 1fdb410..c218269 100644 --- a/client.go +++ b/client.go @@ -155,7 +155,7 @@ func (s *Client) Process(msgpars ...string) (reply *SpamDOut, err error) { return s.simpleCall(PROCESS, msgpars) } -//Same as PROCESS, but return only modified headers, not body (new in protocol 1.4) +//Same as PROCESS, but return only modified headers, not body (new in protocol 1.4) func (s *Client) Headers(msgpars ...string) (reply *SpamDOut, err error) { return s.simpleCall(HEADERS, msgpars) } @@ -263,8 +263,8 @@ func (s *Client) call(cmd string, msgpars []string, onData FnCallback, extraHead cmd = REPORT } - // Create a new connection - stream, err := net.Dial("tcp", s.Host) + // Create a new connection, with a reasonable timeout + stream, err := net.DialTimeout("tcp", s.Host, time.Duration(DEFAULT_TIMEOUT)*time.Second) if err != nil { err = errors.New("Connection dial error to spamd: " + err.Error()) @@ -317,7 +317,7 @@ func processResponse(cmd string, data *bufio.Reader) (returnObj *SpamDOut, err e var result = r.FindStringSubmatch(lineStr) if len(result) < 4 { if cmd != "SKIP" { - err = errors.New("spamd unreconized reply:" + lineStr) + err = errors.New("spamd unrecognized reply:" + lineStr) } else { returnObj.Code = EX_OK returnObj.Message = "SKIPPED"