mirror of
https://github.com/go-i2p/go-meta-listener.git
synced 2025-07-03 13:55:15 -04:00
29 lines
965 B
Go
29 lines
965 B
Go
// Package tcp provides a minimal, production-hardened TCP listener implementation
|
|
// with secure cross-platform defaults suitable for internet-facing services.
|
|
//
|
|
// This package exports a single function Listen() that creates TCP listeners
|
|
// with optimized settings for production workloads including connection reuse,
|
|
// keep-alive monitoring, optimized buffer sizes, and minimal latency configuration.
|
|
//
|
|
// The implementation uses only Go standard library components to ensure
|
|
// compatibility across Windows, Linux, macOS, and BSD systems without
|
|
// requiring platform-specific code or external dependencies.
|
|
//
|
|
// Example usage:
|
|
//
|
|
// listener, err := tcp.Listen("tcp", ":8080")
|
|
// if err != nil {
|
|
// log.Fatalf("Failed to create listener: %v", err)
|
|
// }
|
|
// defer listener.Close()
|
|
//
|
|
// for {
|
|
// conn, err := listener.Accept()
|
|
// if err != nil {
|
|
// log.Printf("Accept error: %v", err)
|
|
// continue
|
|
// }
|
|
// go handleConnection(conn)
|
|
// }
|
|
package tcp
|