tags:

views:

196

answers:

2

I am looking to write a simple client/server utilizing TCP sockets. Any ideas how to do network programming in Go?

+3  A: 

Go has fine support for networking.

For a server, the easiest thing to do is have your main() start a tcp accept loop and spawn a goroutine to handle each request.

The first go software I wrote was a memcached server. You may want to check out gomemcached for an idea of how to get started on servers.

Clients shouldn't be particularly harder. In many cases, it may make the most sense to have a shared client with goroutines for inbound communication much like I use in gomemcached for communicating with the actual storage layer.

Of course, this isn't the only way. Perhaps you'll find something better as you experiment.

Dustin
+1  A: 

Check out the net package.

Jurily