Implements timeouts.

Added DialTimeout and Dial functions.
Fixes issue #27.
This commit is contained in:
Julien Laffaye
2015-03-16 23:45:56 +01:00
parent 5807e676a3
commit a9410e3e51
2 changed files with 22 additions and 7 deletions

View File

@@ -4,6 +4,7 @@ import (
"bytes"
"io/ioutil"
"testing"
"time"
)
const (
@@ -12,7 +13,7 @@ const (
)
func TestConn(t *testing.T) {
c, err := Connect("localhost:21")
c, err := DialTimeout("localhost:21", 5*time.Second)
if err != nil {
t.Fatal(err)
}
@@ -112,8 +113,8 @@ func TestConn(t *testing.T) {
}
// ftp.mozilla.org uses multiline 220 response
func TestConn2(t *testing.T) {
c, err := Connect("ftp.mozilla.org:21")
func TestMultiline(t *testing.T) {
c, err := DialTimeout("ftp.mozilla.org:21", 5*time.Second)
if err != nil {
t.Fatal(err)
}