Help us shape the future of Go! Take the 2026 Go Developer Survey

tcp

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 1, 2017 License: MIT Imports: 5 Imported by: 8

README

TCP Server in Go

This repository contains a simple tcp server in Go, designed to work in a similar way as net/http server.

Documentation

Documentation for this package can be found on https://godoc.org/github.com/Kelindar/tcp.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrServerClosed = errors.New("tcp: Server closed")

ErrServerClosed occurs wehen a tcp server is closed.

Functions

func ServeAsync

func ServeAsync(port int, closing chan bool, acceptHandler OnAccept) error

ServeAsync creates a TCP listener and starts the server.

Types

type OnAccept

type OnAccept func(c net.Conn)

OnAccept is a callback which gets called when a new connection is accepted.

type Server

type Server struct {
	sync.Mutex
	OnAccept OnAccept  // The handler to invoke when a connection is accepted.
	Closing  chan bool // The closing channel.
}

Server represents a TCP server.

func (*Server) Close

func (s *Server) Close() error

Close immediately closes all active listeners.

func (*Server) Serve

func (s *Server) Serve(l net.Listener) error

Serve accepts the connections and fires the callback

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL