該示例性的HTTP服務(wù)器并不為我工作。源代碼:package mainimport ( "fmt" "net/http")func handler(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "Hi there, I love %s!", r.URL.Path[1:])}func main() { http.HandleFunc("/", handler) http.ListenAndServe("127.0.0.1:8080", nil)}當(dāng)我嘗試連接時(shí),我得到的是:$ curl 127.0.0.1:8080curl: (7) Failed to connect to 127.0.0.1 port 8080: Operation timed out$ nc -v -G 5 127.0.0.1 8080nc: connectx to 127.0.0.1 port 8080 (tcp) failed: Operation timed out雖然 nc 嘗試連接 tcpdump 僅顯示 SYN 數(shù)據(jù)包:$ tcpdump -i lo0 port 8080tcpdump: verbose output suppressed, use -v or -vv for full protocol decodelistening on lo0, link-type NULL (BSD loopback), capture size 262144 bytes18:21:30.906638 IP localhost.52799 > localhost.http-alt: Flags [S], seq 3375761924, win 65535, options [mss 16344,nop,wscale 5,nop,nop,TS val 118569352 ecr 0,sackOK,eol], length 018:21:31.006824 IP localhost.52799 > localhost.http-alt: Flags [S], seq 3375761924, win 65535, options [mss 16344,nop,wscale 5,nop,nop,TS val 118569452 ecr 0,sackOK,eol], length 018:21:31.106989 IP localhost.52799 > localhost.http-alt: Flags [S], seq 3375761924, win 65535, options [mss 16344,nop,wscale 5,nop,nop,TS val 118569552 ecr 0,sackOK,eol], length 018:21:31.208141 IP localhost.52799 > localhost.http-alt: Flags [S], seq 3375761924, win 65535, options [mss 16344,nop,wscale 5,nop,nop,TS val 118569653 ecr 0,sackOK,eol], length 018:21:31.308288 IP localhost.52799 > localhost.http-alt: Flags [S], seq 3375761924, win 65535, options [mss 16344,nop,wscale 5,nop,nop,TS val 118569753 ecr 0,sackOK,eol], length 018:21:31.408336 IP localhost.52799 > localhost.http-alt: Flags [S], seq 3375761924, win 65535, options [mss 16344,nop,wscale 5,nop,nop,TS val 118569853 ecr 0,sackOK,eol], length 0當(dāng)我運(yùn)行 nc 時(shí)什么也沒有出現(xiàn),所以它甚至沒有注意到連接嘗試。我沒有啟用防火墻,其他一切正常,只有 Go 程序有這個(gè)問題(特別是我不能使用 docker-machine)我如何解決它?編輯:我假設(shè) #Err35 是:#define EDEADLK 35 /* Resource deadlock would occur */……哇?
查看完整描述