Documentation
¶
Overview ¶
A TCP server. Listens to connections on a port and returns a graphics.gd/classdb/StreamPeerTCP when it gets an incoming connection.
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 ¶
- type Advanced
- type Any
- type Expanded
- type Extension
- type ID
- type Instance
- func (self Instance) AsObject() [1]gd.Object
- func (self Instance) AsRefCounted() [1]gd.RefCounted
- func (self Instance) AsTCPServer() Instance
- func (self Instance) GetLocalPort() int
- func (self Instance) ID() ID
- func (self Instance) IsConnectionAvailable() bool
- func (self Instance) IsListening() bool
- func (self Instance) Listen(port int) error
- func (self *Instance) SetObject(obj [1]gd.Object) bool
- func (self Instance) Stop()
- func (self Instance) TakeConnection() StreamPeerTCP.Instance
- func (self Instance) Virtual(name string) reflect.Value
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 Expanded ¶
func (Expanded) Listen ¶
Listen on the 'port' binding to 'bind_address'.
If 'bind_address' is set as "*" (default), the server will listen on all available addresses (both IPv4 and IPv6).
If 'bind_address' is set as "0.0.0.0" (for IPv4) or "::" (for IPv6), the server will listen on all available addresses matching that IP type.
If 'bind_address' is set to any valid address (e.g. "192.168.1.101", "::1", etc.), the server will only listen on the interface with that address (or fail if no interface with the given address exists).
type Extension ¶
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]) AsRefCounted ¶
func (self *Extension[T]) AsRefCounted() [1]gd.RefCounted
func (*Extension[T]) AsTCPServer ¶
type 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.
type Instance ¶
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 (Instance) AsRefCounted ¶
func (self Instance) AsRefCounted() [1]gd.RefCounted
func (Instance) AsTCPServer ¶
func (Instance) GetLocalPort ¶
Returns the local port this server is listening to.
func (Instance) IsConnectionAvailable ¶
Returns true if a connection is available for taking.
func (Instance) IsListening ¶
Returns true if the server is currently listening for connections.
func (Instance) Listen ¶
Listen on the 'port' binding to 'bind_address'.
If 'bind_address' is set as "*" (default), the server will listen on all available addresses (both IPv4 and IPv6).
If 'bind_address' is set as "0.0.0.0" (for IPv4) or "::" (for IPv6), the server will listen on all available addresses matching that IP type.
If 'bind_address' is set to any valid address (e.g. "192.168.1.101", "::1", etc.), the server will only listen on the interface with that address (or fail if no interface with the given address exists).
func (Instance) TakeConnection ¶
func (self Instance) TakeConnection() StreamPeerTCP.Instance
If a connection is available, returns a StreamPeerTCP with the connection.