connutil

package
v0.4.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 5, 2026 License: GPL-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Copyright (C) 2026 by saba <contact me via issue>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

In addition, no derivative work may use the name or imply association with this application without prior consent.

Copyright (C) 2026 by saba <contact me via issue>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

In addition, no derivative work may use the name or imply association with this application without prior consent.

Copyright (C) 2026 by saba <contact me via issue>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

In addition, no derivative work may use the name or imply association with this application without prior consent.

Copyright (C) 2026 by saba <contact me via issue>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

In addition, no derivative work may use the name or imply association with this application without prior consent.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AbsInt64

func AbsInt64(x int64) int64

func PipeConn

func PipeConn(a, b net.Conn)

PipeConn copies data bidirectionally between a and b, then closes both.

It attempts half-close when supported:

  • after copying src->dst: CloseWrite(dst) and CloseRead(src)

func RunClosers

func RunClosers(closers ...func() error) error

RunClosers executes closers in order and returns the first error.

func TryCloseRead

func TryCloseRead(target any) error

TryCloseRead calls CloseRead when supported.

func TryCloseWrite

func TryCloseWrite(target any) error

TryCloseWrite calls CloseWrite when supported. If half-close isn't supported, it falls back to Close() when available to avoid deadlocks (e.g. WebSocket net.Conn wrappers without CloseWrite).

func WriteFull

func WriteFull(w io.Writer, b []byte) error

WriteFull writes b to w until all bytes are written or an error occurs.

Types

type CloseReader

type CloseReader interface {
	CloseRead() error
}

CloseReader is implemented by conns that support half-close on the read side.

type CloseWriter

type CloseWriter interface {
	CloseWrite() error
}

CloseWriter is implemented by conns that support half-close on the write side.

type ReadOnlyConn

type ReadOnlyConn struct {
	*bytes.Reader
}

ReadOnlyConn wraps a bytes.Reader as a net.Conn for probing/parsing code paths. Writes always fail with io.ErrClosedPipe.

func (*ReadOnlyConn) Close

func (c *ReadOnlyConn) Close() error

func (*ReadOnlyConn) LocalAddr

func (c *ReadOnlyConn) LocalAddr() net.Addr

func (*ReadOnlyConn) RemoteAddr

func (c *ReadOnlyConn) RemoteAddr() net.Addr

func (*ReadOnlyConn) SetDeadline

func (c *ReadOnlyConn) SetDeadline(time.Time) error

func (*ReadOnlyConn) SetReadDeadline

func (c *ReadOnlyConn) SetReadDeadline(time.Time) error

func (*ReadOnlyConn) SetWriteDeadline

func (c *ReadOnlyConn) SetWriteDeadline(time.Time) error

func (*ReadOnlyConn) Write

func (c *ReadOnlyConn) Write([]byte) (int, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL