Okay, I just started learning golang and I like it so far. However I don't find their documentation good for go starters, Here is my problem. I wanted to write little server program that accepts connections and writes something to the client. No problem doing that so far.
However as soon as the thing get a real functionality, I need to be able to handle multiple clients, which I though would also be a good exercise for goroutines.
listener, error := net.Listen("tcp", remote)
con, error := listener.Accept()
go handleClient(&con);
func handleClient(con *net.Conn) {
I've cut most of the code out. The problem is, no matter what I try, I can't pass con
.
con.RemoteAddr undefined (type *net.Conn has no field or method RemoteAddr)
(found that in this example: http://raycompstuff.blogspot.com/2009/12/simpler-chat-server-and-client-in.html). So i tried looking at the documentation, but it just gave me the source of the net package. Read trough the source, and figured it should be
undefined: TCPConn
How can I pass the connection of a client to a goroutine, so i can handle multiple clients at once?