You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 5, 2023. It is now read-only.
Package tcp_server created to help build TCP servers faster.
Install package
go get -u github.com/firstrow/tcp_server@latest
Usage:
NOTICE: OnNewMessage callback will receive new message only if it's ending with \n
package main
import"github.com/firstrow/tcp_server"funcmain() {
server:=tcp_server.New("localhost:9999")
server.OnNewClient(func(c*tcp_server.Client) {
// new client connected// lets send some messagec.Send("Hello")
})
server.OnNewMessage(func(c*tcp_server.Client, messagestring) {
// new message received
})
server.OnClientConnectionClosed(func(c*tcp_server.Client, errerror) {
// connection with client lost
})
server.Listen()
}
Contributing
To hack on this project:
Install as usual (go get -u github.com/firstrow/tcp_server)
Create your feature branch (git checkout -b my-new-feature)
Ensure everything works and the tests pass (go test)
Commit your changes (git commit -am 'Add some feature')
Contribute upstream:
Fork it on GitHub
Add your remote (git remote add fork git@github.com:firstrow/tcp_server.git)
Push to the branch (git push fork my-new-feature)
Create a new Pull Request on GitHub
Notice: Always use the original import path by installing with go get.