mirror of
https://github.com/nxshock/gonx.git
synced 2025-07-01 23:53:35 +05:00
Initial commit
This commit is contained in:
commit
0b430973c9
14 changed files with 460 additions and 0 deletions
34
listener.go
Normal file
34
listener.go
Normal file
|
@ -0,0 +1,34 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"net"
|
||||
)
|
||||
|
||||
// Listener implements net.Listener and additional Add(net.Conn) method.
|
||||
type Listener struct {
|
||||
c chan net.Conn
|
||||
}
|
||||
|
||||
func NewListener() *Listener {
|
||||
c := make(chan net.Conn)
|
||||
|
||||
return &Listener{c: c}
|
||||
}
|
||||
|
||||
func (m *Listener) Add(conn net.Conn) {
|
||||
m.c <- conn
|
||||
}
|
||||
|
||||
func (m *Listener) Accept() (net.Conn, error) {
|
||||
return <-m.c, nil
|
||||
}
|
||||
|
||||
func (m *Listener) Close() error {
|
||||
close(m.c)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Listener) Addr() net.Addr {
|
||||
return nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue