2018-12-01 03:02:41 -05:00
|
|
|
package samforwardertest
|
|
|
|
|
|
|
|
import (
|
2018-12-01 03:09:03 -05:00
|
|
|
"log"
|
2018-12-01 14:40:33 -05:00
|
|
|
"net"
|
2018-12-01 03:09:03 -05:00
|
|
|
"net/http"
|
|
|
|
"testing"
|
|
|
|
"time"
|
2018-12-01 03:02:41 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestTCP(t *testing.T) {
|
2018-12-01 03:09:03 -05:00
|
|
|
go serve()
|
|
|
|
time.Sleep(time.Duration(60 * time.Second))
|
|
|
|
go client()
|
|
|
|
time.Sleep(time.Duration(60 * time.Second))
|
|
|
|
resp, err := http.Get("http://127.0.0.1:" + cport + "/test.html")
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
log.Println(resp)
|
2018-12-01 03:02:41 -05:00
|
|
|
}
|
|
|
|
|
2018-12-01 03:09:03 -05:00
|
|
|
func TestUDP(t *testing.T) {
|
2018-12-01 14:40:33 -05:00
|
|
|
go echo()
|
|
|
|
time.Sleep(time.Duration(60 * time.Second))
|
|
|
|
go serveudp()
|
|
|
|
time.Sleep(time.Duration(60 * time.Second))
|
|
|
|
go clientudp()
|
|
|
|
time.Sleep(time.Duration(60 * time.Second))
|
|
|
|
//conn, err := net.DialUDP("udp", udpserveraddr, "127.0.0.1:"+uport)
|
|
|
|
_, err := net.DialUDP("udp", udpserveraddr, udplocaladdr)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
//log.Println(resp)
|
2018-12-01 03:02:41 -05:00
|
|
|
}
|