aboutsummaryrefslogtreecommitdiff
path: root/binproto.go
diff options
context:
space:
mode:
authorOnur Gündüz <ogunduz@gmail.com>2026-10-08 02:47:42 +0200
committerOnur Gündüz <ogunduz@gmail.com>2026-10-08 02:54:55 +0200
commitd2ae1381c76f53c14fe4e6e4d9b557887cd93187 (patch)
treea4f67413af6bea45a982fba98c5b1826c6fb08e7 /binproto.go
parent4660317cbba12af5ae1546948785301e7f9108b4 (diff)
downloadmuxer-d2ae1381c76f53c14fe4e6e4d9b557887cd93187.tar.gz
muxer-d2ae1381c76f53c14fe4e6e4d9b557887cd93187.zip
Update Go module path and source imports
Diffstat (limited to 'binproto.go')
-rw-r--r--binproto.go60
1 files changed, 0 insertions, 60 deletions
diff --git a/binproto.go b/binproto.go
deleted file mode 100644
index aab7179..0000000
--- a/binproto.go
+++ /dev/null
@@ -1,60 +0,0 @@
-// Package binproto implements low-level support for binary-based two-way
-// communication protocols.
-package binproto
-
-import (
- "bufio"
- "io"
- "net"
- "net/textproto"
-)
-
-// A Conn represents a binary network protocol connection.
-// It consists of a Reader and Writer to manage I/O
-// and a Pipeline (which is borrowed from textproto) to sequence
-// concurrent requests on the connection.
-type Conn struct {
- Reader
- Writer
- textproto.Pipeline
- conn io.ReadWriteCloser
-}
-
-// NewConn returns a new Conn using conn for I/O.
-func NewConn(conn io.ReadWriteCloser) *Conn {
- r, w := NewReader(bufio.NewReader(conn)), NewWriter(bufio.NewWriter(conn))
- return &Conn{
- Reader: *r,
- Writer: *w,
- conn: conn,
- }
-}
-
-// Send is a convenience method that sends a variable number of messages
-// after waiting its turn in the pipeline.
-// Send returns the id of the command, for use with StartResponse and EndResponse.
-func (c *Conn) Send(m ...*Message) (id uint, err error) {
- id = c.Next()
- c.StartRequest(id)
- err = c.WriteMessage(m...)
- c.EndRequest(id)
- if err != nil {
- return 0, err
- }
- return id, nil
-}
-
-// Close closes the connection.
-func (c *Conn) Close() error {
- return c.conn.Close()
-}
-
-// Dial connects to the given address on the given network using net.Dial
-// and then returns a new Conn for the connection.
-func Dial(network, addr string) (*Conn, error) {
- c, err := net.Dial(network, addr)
- if err != nil {
- return nil, err
- }
- return NewConn(c), nil
-}