StreamPeerTCP

package
v0.0.0-...-357ca8a Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2025 License: MIT Imports: 24 Imported by: 0

Documentation

Overview

A stream peer that handles TCP connections. This object can be used to connect to TCP servers, or also is returned by a TCP server.

Note: When exporting to Android, make sure to enable the INTERNET permission in the Android export preset before exporting the project or using one-click deploy. Otherwise, network communication of any kind will be blocked by Android.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Advanced

type Advanced = class

Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.

type Any

type Any interface {
	gd.IsClass
	AsStreamPeerTCP() Instance
}

type Expanded

type Expanded = MoreArgs

type Extension

type Extension[T gdclass.Interface] struct{ gdclass.Extension[T, Instance] }

Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this Extension

func (*Extension[T]) AsObject

func (self *Extension[T]) AsObject() [1]gd.Object

func (*Extension[T]) AsRefCounted

func (self *Extension[T]) AsRefCounted() [1]gd.RefCounted

func (*Extension[T]) AsStreamPeer

func (self *Extension[T]) AsStreamPeer() StreamPeer.Instance

func (*Extension[T]) AsStreamPeerTCP

func (self *Extension[T]) AsStreamPeerTCP() Instance

type ID

type ID Object.ID

ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.

func (ID) Instance

func (id ID) Instance() (Instance, bool)

type Instance

type Instance [1]gdclass.StreamPeerTCP

Instance of the class with convieniently typed arguments and results.

var Nil Instance

Nil is a nil/null instance of the class. Equivalent to the zero value.

func New

func New() Instance

func (Instance) AsObject

func (self Instance) AsObject() [1]gd.Object

func (Instance) AsRefCounted

func (self Instance) AsRefCounted() [1]gd.RefCounted

func (Instance) AsStreamPeer

func (self Instance) AsStreamPeer() StreamPeer.Instance

func (Instance) AsStreamPeerTCP

func (self Instance) AsStreamPeerTCP() Instance

func (Instance) Bind

func (self Instance) Bind(port int) error

Opens the TCP socket, and binds it to the specified local address.

This method is generally not needed, and only used to force the subsequent call to ConnectToHost to use the specified 'host' and 'port' as source address. This can be desired in some NAT punchthrough techniques, or when forcing the source network interface.

func (Instance) ConnectToHost

func (self Instance) ConnectToHost(host string, port int) error

Connects to the specified host:port pair. A hostname will be resolved if valid. Returns [Ok] on success.

func (Instance) DisconnectFromHost

func (self Instance) DisconnectFromHost()

Disconnects from host.

func (Instance) GetConnectedHost

func (self Instance) GetConnectedHost() string

Returns the IP of this peer.

func (Instance) GetConnectedPort

func (self Instance) GetConnectedPort() int

Returns the port of this peer.

func (Instance) GetLocalPort

func (self Instance) GetLocalPort() int

Returns the local port to which this peer is bound.

func (Instance) GetStatus

func (self Instance) GetStatus() Status

Returns the status of the connection.

func (Instance) ID

func (self Instance) ID() ID

func (Instance) MoreArgs

func (self Instance) MoreArgs() MoreArgs

MoreArgs enables certain functions to be called with additional 'optional' arguments.

func (Instance) Poll

func (self Instance) Poll() error

Poll the socket, updating its state. See GetStatus.

func (Instance) SetNoDelay

func (self Instance) SetNoDelay(enabled bool)

If 'enabled' is true, packets will be sent immediately. If 'enabled' is false (the default), packet transfers will be delayed and combined using Nagle's algorithm.

Note: It's recommended to leave this disabled for applications that send large packets or need to transfer a lot of data, as enabling this can decrease the total available bandwidth.

func (*Instance) SetObject

func (self *Instance) SetObject(obj [1]gd.Object) bool

func (Instance) Virtual

func (self Instance) Virtual(name string) reflect.Value

type MoreArgs

type MoreArgs [1]gdclass.StreamPeerTCP

MoreArgs is a container for Instance functions with additional 'optional' arguments.

func (MoreArgs) Bind

func (self MoreArgs) Bind(port int, host string) error

Opens the TCP socket, and binds it to the specified local address.

This method is generally not needed, and only used to force the subsequent call to ConnectToHost to use the specified 'host' and 'port' as source address. This can be desired in some NAT punchthrough techniques, or when forcing the source network interface.

type Status

type Status int //gd:StreamPeerTCP.Status
const (
	// The initial status of the [StreamPeerTCP]. This is also the status after disconnecting.
	//
	// [StreamPeerTCP]: https://pkg.go.dev/graphics.gd/classdb/StreamPeerTCP
	StatusNone Status = 0
	// A status representing a [StreamPeerTCP] that is connecting to a host.
	//
	// [StreamPeerTCP]: https://pkg.go.dev/graphics.gd/classdb/StreamPeerTCP
	StatusConnecting Status = 1
	// A status representing a [StreamPeerTCP] that is connected to a host.
	//
	// [StreamPeerTCP]: https://pkg.go.dev/graphics.gd/classdb/StreamPeerTCP
	StatusConnected Status = 2
	// A status representing a [StreamPeerTCP] in error state.
	//
	// [StreamPeerTCP]: https://pkg.go.dev/graphics.gd/classdb/StreamPeerTCP
	StatusError Status = 3
)

Jump to

Keyboard shortcuts

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