Skip to content

Go library for serving WebSocket or TCP clients on the same listener

License

Notifications You must be signed in to change notification settings

matevzmihalic/wstcp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WebSocket | TCP

is a Go library for serving WebSocket or TCP clients on the same listener. It can be used as a drop in replacement to add WebSocket support to existing TCP servers.

It automatically detects WebSocket clients, upgrades them and then takes care of headers and control packets.

Usage

ln, _ := net.Listen("tcp", "localhost:9999")
for {
    rawConn, _ := ln.Accept()
    go func() {
        conn, _ := wstcp.New(rawConn)
        // conn can now be used the same way rawConn would be
        // but it can handle WebSocket or raw TCP clients
    }()
}

About

Go library for serving WebSocket or TCP clients on the same listener

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages