Documentation ¶
Index ¶
Constants ¶
const (
DefaultMaxMessageBytes = 2048
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type HTTPUClient ¶
type HTTPUClient struct {
// contains filtered or unexported fields
}
HTTPUClient is a client for dealing with HTTPU (HTTP over UDP). Its typical function is for HTTPMU, and particularly SSDP.
func NewHTTPUClient ¶
func NewHTTPUClient() (*HTTPUClient, error)
NewHTTPUClient creates a new HTTPUClient, opening up a new UDP socket for the purpose.
func (*HTTPUClient) Close ¶
func (httpu *HTTPUClient) Close() error
Close shuts down the client. The client will no longer be useful following this.
func (*HTTPUClient) Do ¶
func (httpu *HTTPUClient) Do(req *http.Request, timeout time.Duration, numSends int) ([]*http.Response, error)
Do performs a request. The timeout is how long to wait for before returning the responses that were received. An error is only returned for failing to send the request. Failures in receipt simply do not add to the resulting responses.
Note that at present only one concurrent connection will happen per HTTPUClient.
type Handler ¶
type Handler interface { // ServeMessage is called for each HTTPU message received. peerAddr contains // the address that the message was received from. ServeMessage(r *http.Request) }
Handler is the interface by which received HTTPU messages are passed to handling code.
type HandlerFunc ¶
HandlerFunc is a function-to-Handler adapter.
func (HandlerFunc) ServeMessage ¶
func (f HandlerFunc) ServeMessage(r *http.Request)
type Server ¶
type Server struct { Addr string // UDP address to listen on Multicast bool // Should listen for multicast? Interface *net.Interface // Network interface to listen on for multicast, nil for default multicast interface Handler Handler // handler to invoke MaxMessageBytes int // maximum number of bytes to read from a packet, DefaultMaxMessageBytes if 0 }
A Server defines parameters for running an HTTPU server.
func (*Server) ListenAndServe ¶
ListenAndServe listens on the UDP network address srv.Addr. If srv.Multicast is true, then a multicast UDP listener will be used on srv.Interface (or default interface if nil).