/tcpsock

Package tcpsock provides easy to use interfaces for TCP I/O, including both TcpServer and TcpClient.

Primary LanguageGoBSD 2-Clause "Simplified" LicenseBSD-2-Clause

tcpsock

Package tcpsock provides easy to use interfaces for TCP I/O.

How to use

server:

server := tcpsock.NewTcpServer(listenPort, acceptTimeout, onConnConnect, onConnClose, onProtocol)
go server.Serve()
<-shutdown
server.Close()

client:

client := tcpsock.NewTcpClient(ServerAddr, onConnect, onClose, onProtocol)
go client.Run()
<-shutdown
client.Close()

There're more detailed demos which use custom binary protocols, like: