knetwork

package
v0.0.0-...-66343a0 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: BSD-3-Clause, BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NopWriteCloser

func NopWriteCloser(writer io.Writer) io.WriteCloser

NopWriteCloser turns any io.Writer into a io.WriteCloser with a nop closer.

This can also be used to ignore Close() events on another WriteCloser. If you need a NopCloser for read, you can use io.NopCloser.

IMPORTANT: discarding a Close() will of course result in the file remaining

open, and corresponding buffers not being flushsed. Be careful
when using this.

func ReadOnlyClose

func ReadOnlyClose(woc ReadOnlyCloser) io.ReadCloser

ReadOnlyClose returns an io.ReadCloser that will only close the read channel of the connection passed.

When the object is "Close()", "ReadClose()" will be invoked instead.

func WriteOnlyClose

func WriteOnlyClose(woc WriteOnlyCloser) io.WriteCloser

WriteOnlyClose returns an io.WriteCloser that will only close the write channel of the connection passed.

When the object is "Close()", "WriteClose()" will be invoked instead.

Types

type CleanupListener

type CleanupListener struct {
	FileListener
	Path string
}

CleanupListener deletes the file at `path` after delegating to the wrapped FileListener's Close().

func (*CleanupListener) Close

func (c *CleanupListener) Close() error

type FileListener

type FileListener interface {
	net.Listener
	File() (*os.File, error)
}

FileListener can represent any net.Listener that also has a File() method.

type PortDescriptor

type PortDescriptor struct {
	net.Listener
}

func AllocatePort

func AllocatePort() (*PortDescriptor, error)

func (*PortDescriptor) Address

func (pd *PortDescriptor) Address() (*net.TCPAddr, error)

type ReadOnlyCloser

type ReadOnlyCloser interface {
	io.Reader
	CloseRead() error
}

ReadOnlyCloser is any object that is capable of closing the read direction without closing the write direction.

This is typical of eg, TCP connection where a shutdown() call can close one direction but not the other.

type WriteOnlyCloser

type WriteOnlyCloser interface {
	io.Writer
	CloseWrite() error
}

WriteOnlyCloser is any object that is capable of closing the write direction without closing the read direction.

This is typical of eg, TCP connection where a shutdown() call can close one direction but not the other.

Directories

Path Synopsis
+build !release
+build !release

Jump to

Keyboard shortcuts

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