tcp

package
v0.23.5 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2023 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Overview

Package tcp provides functionalities for a TCP client.

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 represents a TCP client for interacting with remote services.

func NewClient

func NewClient() *Client

NewClient creates a new TCP client.

func (*Client) Connect

func (c *Client) Connect(address, port string) (*service.Service, error)

Connect establishes a connection to a remote service.

Parameters: - address: string The address of the remote service. - port: string The port of the remote service.

Returns: - s: *service.Service The connected service. - error: An error if any.

func (*Client) Disconnect

func (c *Client) Disconnect(services ...string) error

Disconnect closes connections to one or more services.

Parameters: - services: ...string A variadic list of service names to disconnect from.

Returns: - error: An error if any.

func (*Client) Send

func (c *Client) Send(callback func(...*generated.Response), queries ...*service.Exchange) error

Send sends requests to remote services and handles the responses.

Parameters: - callback: func(...*generated.Response) A function to handle responses. - queries: ...*service.Exchange An array of service exchanges containing requests and their associated services.

Returns: - error: An error if any.

type Server

type Server struct {
	Address string // Address to listen on
	// contains filtered or unexported fields
}

Server represents a TCP server and contains information about the address it listens on and the underlying network listener.

func NewServer

func NewServer(address string) *Server

NewServer creates a new Server instance with the specified listening address.

func (*Server) Register

func (s *Server) Register(api api.APInterface)

Register is a method for registering API handlers with the server.

Parameters: - api: api.APInterface - The API interface to register handlers from.

func (*Server) Start

func (s *Server) Start() error

Start starts the TCP server, allowing it to accept incoming connections.

Returns: - error: An error if the server is already started or if there was an issue starting the server.

func (*Server) Stop

func (s *Server) Stop() error

Stop stops the TCP server.

Returns: - error: An error if the server is not active or if there was an issue stopping the server.

Jump to

Keyboard shortcuts

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