-
Notifications
You must be signed in to change notification settings - Fork 46
/
push.go
42 lines (35 loc) · 1.06 KB
/
push.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"
)
// PushSocket is a ZMQ_PUSH socket type.
// See: http://rfc.zeromq.org/spec:41
type PushSocket struct {
*Socket
}
// NewPush accepts a zmtp.SecurityMechanism and returns
// a PushSocket as a gomq.Push interface.
func NewPush(mechanism zmtp.SecurityMechanism) *PushSocket {
return &PushSocket{
Socket: NewSocket(false, zmtp.PushSocketType, 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 *PushSocket) Bind(endpoint string) (net.Addr, error) {
return BindServer(s, endpoint)
}
// Connect accepts a zeromq endpoint and connects the
// client socket to it. Currently the only transport
// supported is TCP. The endpoint string should be
// in the format "tcp://<address>:<port>".
func (s *PushSocket) Connect(endpoint string) error {
return ConnectClient(s, endpoint)
}
var (
_ Client = (*PushSocket)(nil)
_ Server = (*PushSocket)(nil)
)