This repository was archived by the owner on May 1, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathsocket.go
More file actions
42 lines (33 loc) · 1.19 KB
/
socket.go
File metadata and controls
42 lines (33 loc) · 1.19 KB
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 webwire
import (
"io"
"net"
"time"
"github.com/qbeon/webwire-go/message"
)
// Socket defines the abstract socket implementation interface
type Socket interface {
// GetWriter returns a writer for the next message to send. The writer's
// Close method flushes the written message to the network. In case of
// concurrent use GetWriter will block until the previous writer is closed
// and a new one is available
GetWriter() (io.WriteCloser, error)
// Read blocks the calling goroutine and awaits an incoming message. If
// deadline is 0 then Read will never timeout. In case of concurrent use
// Read will block until the previous call finished
Read(into *message.Message, deadline time.Time) ErrSockRead
// IsConnected returns true if the given socket maintains an open connection
// or otherwise return false
IsConnected() bool
// RemoteAddr returns the address of the remote client or nil if the client
// is not connected
RemoteAddr() net.Addr
// Close closes the socket
Close() error
}
// ClientSocket defines the abstract client socket implementation interface
type ClientSocket interface {
// Dial connects the socket to the server
Dial(deadline time.Time) error
Socket
}