Struct gdnative_bindings_lily::StreamPeerTCP [−][src]
pub struct StreamPeerTCP { /* fields omitted */ }
Expand description
core class StreamPeerTCP
inherits StreamPeer
(reference counted).
Official documentation
See the documentation of this class in the Godot engine’s official documentation. The method descriptions are generated from it and typically contain code samples in GDScript, not Rust.
Memory management
The lifetime of this object is automatically managed through reference counting.
Class hierarchy
StreamPeerTCP inherits methods from:
Safety
All types in the Godot API have “interior mutability” in Rust parlance.
To enforce that the official thread-safety guidelines are
followed, the typestate pattern is used in the Ref
and TRef
smart pointers,
and the Instance
API. The typestate Access
in these types tracks whether the
access is unique, shared, or exclusive to the current thread. For more information,
see the type-level documentation on Ref
.
Implementations
Constants
Creates a new instance of this object.
This is a reference-counted type. The returned object is automatically managed
by Ref
.
Connects to the specified host:port
pair. A hostname will be resolved if valid. Returns [constant OK] on success or [constant FAILED] on failure.
Disconnects from host.
Returns the IP of this peer.
Returns the port of this peer.
Returns the status of the connection, see [enum Status].
Returns true
if this peer is currently connected to a host, false
otherwise.
Disables Nagle’s algorithm to improve latency for small packets. Note: For applications that send large packets or need to transfer a lot of data, this can decrease the total available bandwidth.
Methods from Deref<Target = StreamPeer>
Returns the amount of bytes this StreamPeer has available.
Returns a chunk data with the received bytes. The amount of bytes to be received can be requested in the bytes
argument. If not enough bytes are available, the function will block until the desired amount is received. This function returns two values, an [enum @GlobalScope.Error] code and a data array.
Gets a double-precision float from the stream.
Returns a chunk data with the received bytes. The amount of bytes to be received can be requested in the “bytes” argument. If not enough bytes are available, the function will return how many were actually received. This function returns two values, an [enum @GlobalScope.Error] code, and a data array.
Gets a string with byte-length bytes
from the stream. If bytes
is negative (default) the length will be read from the stream using the reverse process of [method put_string].
Default Arguments
bytes
--1
Gets an UTF-8 string with byte-length bytes
from the stream (this decodes the string sent as UTF-8). If bytes
is negative (default) the length will be read from the stream using the reverse process of [method put_utf8_string].
Default Arguments
bytes
--1
Gets a Variant from the stream. If allow_objects
is true
, decoding objects is allowed.
Warning: Deserialized objects can contain code which gets executed. Do not use this option if the serialized object comes from untrusted sources to avoid potential security threats such as remote code execution.
Default Arguments
allow_objects
-false
If true
, this StreamPeer will using big-endian format for encoding and decoding.
Sends a chunk of data through the connection, blocking if necessary until the data is done sending. This function returns an [enum @GlobalScope.Error] code.
Puts a double-precision float into the stream.
Sends a chunk of data through the connection. If all the data could not be sent at once, only part of it will. This function returns two values, an [enum @GlobalScope.Error] code and an integer, describing how much data was actually sent.
Sample code is GDScript unless otherwise noted.
Puts a zero-terminated ASCII string into the stream prepended by a 32-bit unsigned integer representing its size. Note: To put an ASCII string without prepending its size, you can use [method put_data]:
put_data("Hello world".to_ascii())
Sample code is GDScript unless otherwise noted.
Puts a zero-terminated UTF-8 string into the stream prepended by a 32 bits unsigned integer representing its size. Note: To put an UTF-8 string without prepending its size, you can use [method put_data]:
put_data("Hello world".to_utf8())
Puts a Variant into the stream. If full_objects
is true
encoding objects is allowed (and can potentially include code).
Default Arguments
full_objects
-false
If true
, this StreamPeer will using big-endian format for encoding and decoding.
Trait Implementations
type Target = StreamPeer
type Target = StreamPeer
The resulting type after dereferencing.
Dereferences the value.
Mutably dereferences the value.
type RefKind = RefCounted
type RefKind = RefCounted
Creates an explicitly null reference of Self
as a method argument. This makes type
inference easier for the compiler compared to Option
. Read more
Creates a new instance of Self
using a zero-argument constructor, as a Unique
reference. Read more
Performs a dynamic reference downcast to target type. Read more
Performs a static reference upcast to a supertype that is guaranteed to be valid. Read more
Creates a persistent reference to the same Godot object with shared thread access. Read more
unsafe fn assume_thread_local(&self) -> Ref<Self, ThreadLocal> where
Self: GodotObject<RefKind = RefCounted>,
unsafe fn assume_thread_local(&self) -> Ref<Self, ThreadLocal> where
Self: GodotObject<RefKind = RefCounted>,
Creates a persistent reference to the same Godot object with thread-local thread access. Read more
Creates a persistent reference to the same Godot object with unique access. Read more
Recovers a instance ID previously returned by Object::get_instance_id
if the object is
still alive. See also TRef::try_from_instance_id
. Read more
Auto Trait Implementations
impl RefUnwindSafe for StreamPeerTCP
impl !Send for StreamPeerTCP
impl !Sync for StreamPeerTCP
impl Unpin for StreamPeerTCP
impl UnwindSafe for StreamPeerTCP