socket

package
v0.0.0-...-a7c7adb Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Socket

type Socket struct {
	FileDescriptor int //文件描述符
}

func Listen

func Listen(ip string, port int) (*Socket, error)

监听一个 Socket

func (*Socket) Close

func (socket *Socket) Close() error

3.关闭 socket 可以调用 close()[9

func (Socket) Read

func (socket Socket) Read(bytes []byte) (int, error)

1.实现 io.Reader 这个接口

func (*Socket) String

func (socket *Socket) String() string

为了稍后能打印一些有用的错误和日志,我们也需要实现 fmt.Stringer 接口。我们通过不同的文件描述符来区分不同的 socket

func (Socket) Write

func (socket Socket) Write(bytes []byte) (int, error)

2.实现 io.Writer 接口

Jump to

Keyboard shortcuts

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