FAQ

On Wed, Jan 16, 2013 at 11:39 AM, Tong Sun wrote:
I'm trying with the socket programming in go, following the sample code
from
https://github.com/astaxie/build-web-application-with-golang/blob/master/08.1.md,
but get "connection reset by peer" error:

$ go run Socket-Client.go localhost:1200
Fatal error: read tcp 127.0.0.1:1200: connection reset by peerexit status
1

$ netstat -a | grep 1200
tcp 0 0 *:1200 *:* LISTEN


I've isolate the problem to be on the server side, because the client can
connect to other normal sites just fine.

I've paste the server code here,
http://play.golang.org/p/YrohMJWuIw

Please help to see what's going wrong.
Resolved: there is nothing wrong with the server code, but with the
my client Socket-Client.go. The book doesn't mention what client code can
interact with the server code, so I assumed the previous working example.

Finally found the real solution at
http://jan.newmarch.name/go/socket/chapter-socket.html

in which it says,

We haven't built a client. That is easy, just changing the previous client
to omit the initial write. Alternatively, just open up a telnet connection
to that host:

telnet localhost 1200

This will produce output such as

$telnet localhost 1200

Trying ::1...

Connected to localhost.

Escape character is '^]'.

Sun Aug 29 17:25:19 EST 2010Connection closed by foreign host.

where "Sun Aug 29 17:25:19 EST 2010" is the output from the server.

which is how Dave Cheney tested the server.

@Asta, please update your server code with mine because yours has a typo.
Aslo,please update your single-threaded server code with this,
http://play.golang.org/p/2xSCHX1Sf4, because yours does not compile. Thanks
for the great book (Maybe you want to add the above info about client code
& server testing).

Ok,
thanks again everyone for your helps.

--

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedJan 18, '13 at 4:34a
activeJan 18, '13 at 5:46a
posts2
users2
websitegolang.org

2 users in discussion

Asta Xie: 1 post Tong Sun: 1 post

People

Translate

site design / logo © 2021 Grokbase