socket

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: May 5, 2025 License: Apache-2.0 Imports: 5 Imported by: 2

Documentation

Overview

Package socket provides socket client and server implementations.

Package socket provides socket client and server implementations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a struct that provides client related methods.

func (*Client) Close

func (this *Client) Close() error

Close is close the connection.

ex) err := client.Close()

func (*Client) Connect

func (this *Client) Connect(network, address string) error

Connect is connect to the address.

ex) err := client.Connect("tcp", "127.0.0.1:10000")

func (*Client) GetLocalAddr

func (this *Client) GetLocalAddr() net.Addr

GetRemoteAddr is get the local Addr

ex) addr := client.GetLocalAddr()

func (*Client) GetRemoteAddr

func (this *Client) GetRemoteAddr() net.Addr

GetRemoteAddr is get the remote Addr

ex) addr := client.GetRemoteAddr()

func (*Client) Read

func (this *Client) Read(recvSize int) (string, error)

Read is read data from connection.

ex) readData, err := client.Read(1024)

func (*Client) Write

func (this *Client) Write(data string) (int, error)

Write is write data to connection.

ex) writeLen, err := client.Write("example")

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server is a struct that provides server related methods.

func (*Server) GetCondition

func (this *Server) GetCondition() bool

GetCondition is get the condition

ex) condition := server.GetCondition()

func (*Server) Start

func (this *Server) Start(network, address string, clientPoolSize int, acceptSuccessFunc func(client Client), acceptFailureFunc func(err error)) error

Start is start the server.

ex) err := server.Start("tcp", "127.0.0.1:10000", 1024, func(client Client) {...}, func(err error) {...})

func (*Server) Stop

func (this *Server) Stop() error

Stop is stop the server.

ex) err := server.Stop()

Jump to

Keyboard shortcuts

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