-
Notifications
You must be signed in to change notification settings - Fork 46
/
pull.go
42 lines (35 loc) · 1.06 KB
/
pull.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package gomq
import (
"net"
"github.com/zeromq/gomq/zmtp"
)
// PullSocket is a ZMQ_PULL socket type.
// See: http://rfc.zeromq.org/spec:41
type PullSocket struct {
*Socket
}
// NewPull accepts a zmtp.SecurityMechanism and returns
// a PullSocket as a gomq.Pull interface.
func NewPull(mechanism zmtp.SecurityMechanism) *PullSocket {
return &PullSocket{
Socket: NewSocket(false, zmtp.PullSocketType, nil, mechanism),
}
}
// Bind accepts a zeromq endpoint and binds the
// push socket to it. Currently the only transport
// supported is TCP. The endpoint string should be
// in the format "tcp://<address>:<port>".
func (s *PullSocket) Bind(endpoint string) (net.Addr, error) {
return BindServer(s, endpoint)
}
// Connect accepts a zeromq endpoint and connects the
// pull socket to it. Currently the only transport
// supported is TCP. The endpoint string should be
// in the format "tcp://<address>:<port>".
func (c *PullSocket) Connect(endpoint string) error {
return ConnectClient(c, endpoint)
}
var (
_ Client = (*PullSocket)(nil)
_ Server = (*PullSocket)(nil)
)