23 lines
488 B
Go
23 lines
488 B
Go
package reactive
|
|
|
|
import (
|
|
"net"
|
|
"net/netip"
|
|
)
|
|
|
|
func Listen(network string, address string) (Observable[net.Conn], error) {
|
|
lis, err := net.Listen(network, address)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return BlockingLoop(lis.Accept), nil
|
|
}
|
|
|
|
func ListenTCP(network string, address netip.AddrPort) (Observable[*net.TCPConn], error) {
|
|
lis, err := net.ListenTCP("tcp", net.TCPAddrFromAddrPort(address))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return BlockingLoop(lis.AcceptTCP), nil
|
|
}
|