Inheritance #
- AudioServer
- CameraServer
- ClassDB
- DisplayServer
- EditorFileSystemDirectory
- EditorInterface
- EditorPaths
- EditorSelection
- EditorUndoRedoManager
- EditorVCSInterface
- Engine
- EngineDebugger
- FramebufferCacheRD
- GDExtensionManager
- Geometry2D
- Geometry3D
- IP
- Input
- InputMap
- JNISingleton
- JSONRPC
- JavaClassWrapper
- JavaScriptBridge
- MainLoop (1)
- Marshalls
- MovieWriter
- NativeMenu
- NavigationMeshGenerator
- NavigationServer2D
- NavigationServer3D
- Node (21)
- OS
- OpenXRExtensionWrapperExtension
- OpenXRInteractionProfileMetadata
- Performance
- PhysicsDirectBodyState2D (1)
- PhysicsDirectBodyState3D (1)
- PhysicsDirectSpaceState2D (1)
- PhysicsDirectSpaceState3D (1)
- PhysicsServer2D (1)
- PhysicsServer2DManager
- PhysicsServer3D (1)
- PhysicsServer3DManager
- PhysicsServer3DRendering
ServerHandler
- ProjectSettings
- RefCounted (121)
- RenderData (2)
- RenderSceneData (2)
- RenderingDevice
- RenderingServer
- ResourceLoader
- ResourceSaver
- ResourceUID
- ScriptLanguage (1)
- ShaderIncludeDB
- TextServerManager
- ThemeDB
- TileData
- Time
- TranslationServer
- TreeItem
- UndoRedo
- UniformSetCacheRD
- WorkerThreadPool
- XRServer
- XRVRS
- AESContext
- AStar2D
- AStar3D
- AStarGrid2D
- AudioEffectInstance (1)
- AudioSample
- AudioSamplePlayback
- AudioStreamPlayback (5)
- CameraFeed
- CharFXTransform
- ConfigFile
- Crypto
- DTLSServer
- DirAccess
- ENetConnection
- EditorContextMenuPlugin
- EditorDebuggerPlugin
- EditorDebuggerSession
- EditorExportPlatform (6)
- EditorExportPlugin
- EditorExportPreset
- EditorFeatureProfile
- EditorFileSystemImportFormatSupportQuery
- EditorInspectorPlugin
- EditorResourceConversionPlugin
- EditorResourcePreviewGenerator
- EditorResourceTooltipPlugin
- EditorSceneFormatImporter (4)
- EditorScenePostImport
- EditorScenePostImportPlugin
- EditorScript
- EditorTranslationParserPlugin
- EncodedObjectAsID
- EngineProfiler
- Expression
- FileAccess
- GLTFObjectModelProperty
- HMACContext
- HTTPClient
- HashingContext
- ImageFormatLoader (1)
- JavaClass
- JavaObject
- JavaScriptObject
- KinematicCollision2D
- KinematicCollision3D
- Lightmapper (1)
- MeshConvexDecompositionSettings
- MeshDataTool
- MultiplayerAPI (2)
- Mutex
- NavigationPathQueryParameters2D
- NavigationPathQueryParameters3D
- NavigationPathQueryResult2D
- NavigationPathQueryResult3D
- Node3DGizmo (1)
- OggPacketSequencePlayback
- OpenXRAPIExtension
- PCKPacker
- PackedDataContainerRef
- PacketPeer (8)
- PhysicsPointQueryParameters2D
- PhysicsPointQueryParameters3D
- PhysicsRayQueryParameters2D
- PhysicsRayQueryParameters3D
- PhysicsShapeQueryParameters2D
- PhysicsShapeQueryParameters3D
- PhysicsTestMotionParameters2D
- PhysicsTestMotionParameters3D
- PhysicsTestMotionResult2D
- PhysicsTestMotionResult3D
- RDAttachmentFormat
- RDFramebufferPass
- RDPipelineColorBlendState
- RDPipelineColorBlendStateAttachment
- RDPipelineDepthStencilState
- RDPipelineMultisampleState
- RDPipelineRasterizationState
- RDPipelineSpecializationConstant
- RDSamplerState
- RDShaderSource
- RDTextureFormat
- RDTextureView
- RDUniform
- RDVertexAttribute
- RandomNumberGenerator
- RegEx
- RegExMatch
- RenderSceneBuffers (2)
- RenderSceneBuffersConfiguration
- Resource (103)
- ResourceFormatLoader
- ResourceFormatSaver
- ResourceImporter (16)
- SceneState
- SceneTreeTimer
- Semaphore
- SkinReference
- StreamPeer (5)
- SurfaceTool
- TCPServer
- TLSOptions
- TextLine
- TextParagraph
- TextServer (1)
- Thread
- TranslationDomain
- TriangleMesh
- Tween
- Tweener (5)
- UDPServer
- UPNP
- UPNPDevice
- WeakRef
- WebRTCPeerConnection (1)
- XMLParser
- XRInterface (4)
- XRPose
- XRTracker (2)
- ZIPPacker
- ZIPReader
Table of contents
-
var big_endian: bool = false -
func get_8() -> int -
func get_16() -> int -
func get_32() -> int -
func get_64() -> int -
const func get_available_bytes() -> int -
func get_data(bytes: int) -> Array -
func get_double() -> float -
func get_float() -> float -
func get_half() -> float -
func get_partial_data(bytes: int) -> Array -
func get_string(bytes: int = -1) -> String -
func get_u8() -> int -
func get_u16() -> int -
func get_u32() -> int -
func get_u64() -> int -
func get_utf8_string(bytes: int = -1) -> String -
func get_var(allow_objects: bool = false) -> Variant -
func put_8(value: int) -> void -
func put_16(value: int) -> void -
func put_32(value: int) -> void -
func put_64(value: int) -> void -
func put_data(data: PackedByteArray) -> intError -
func put_double(value: float) -> void -
func put_float(value: float) -> void -
func put_half(value: float) -> void -
func put_partial_data(data: PackedByteArray) -> Array -
func put_string(value: String) -> void -
func put_u8(value: int) -> void -
func put_u16(value: int) -> void -
func put_u32(value: int) -> void -
func put_u64(value: int) -> void -
func put_utf8_string(value: String) -> void -
func put_var(full_objects: bool = false) -> void
StreamPeer #
is_refcounted, core, not_builtin_classes
Abstract base class for interacting with streams.
StreamPeer is an abstract base class mostly used for stream-based protocols (such as TCP). It provides an API for sending and receiving data through streams as raw data or strings.
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.
Members #
var big_endian: bool = false#
If true, this StreamPeer will using big-endian format for encoding and decoding.
Methods #
func get_8() -> int#
Gets a signed byte from the stream.
func get_16() -> int#
Gets a signed 16-bit value from the stream.
func get_32() -> int#
Gets a signed 32-bit value from the stream.
func get_64() -> int#
Gets a signed 64-bit value from the stream.
const func get_available_bytes() -> int#
Returns the number of bytes this StreamPeer has available.
func get_data(bytes: int) -> Array#
Returns a chunk data with the received bytes. The number 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 Error code and a data array.
func get_double() -> float#
Gets a double-precision float from the stream.
func get_float() -> float#
Gets a single-precision float from the stream.
func get_half() -> float#
Gets a half-precision float from the stream.
func get_partial_data(bytes: int) -> Array#
Returns a chunk data with the received bytes. The number 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 Error code, and a data array.
func get_string(bytes: int = -1) -> String#
Gets an ASCII 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 put_string.
func get_u8() -> int#
Gets an unsigned byte from the stream.
func get_u16() -> int#
Gets an unsigned 16-bit value from the stream.
func get_u32() -> int#
Gets an unsigned 32-bit value from the stream.
func get_u64() -> int#
Gets an unsigned 64-bit value from the stream.
func get_utf8_string(bytes: int = -1) -> String#
Gets a 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 put_utf8_string.
func get_var(allow_objects: bool = false) -> Variant#
Gets a Variant from the stream. If allow_objects is true, decoding objects is allowed.
Internally, this uses the same decoding mechanism as the @GlobalScope.bytes_to_var method.
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.
func put_8(value: int) -> void#
Puts a signed byte into the stream.
func put_16(value: int) -> void#
Puts a signed 16-bit value into the stream.
func put_32(value: int) -> void#
Puts a signed 32-bit value into the stream.
func put_64(value: int) -> void#
Puts a signed 64-bit value into the stream.
func put_data(data: PackedByteArray) -> intError#
Sends a chunk of data through the connection, blocking if necessary until the data is done sending. This function returns an Error code.
func put_double(value: float) -> void#
Puts a double-precision float into the stream.
func put_float(value: float) -> void#
Puts a single-precision float into the stream.
func put_half(value: float) -> void#
Puts a half-precision float into the stream.
func put_partial_data(data: PackedByteArray) -> Array#
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 Error code and an integer, describing how much data was actually sent.
func put_string(value: String) -> void#
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 put_data:
GDScript
put_data("Hello world".to_ascii_buffer())C#
PutData("Hello World".ToAsciiBuffer());func put_u8(value: int) -> void#
Puts an unsigned byte into the stream.
func put_u16(value: int) -> void#
Puts an unsigned 16-bit value into the stream.
func put_u32(value: int) -> void#
Puts an unsigned 32-bit value into the stream.
func put_u64(value: int) -> void#
Puts an unsigned 64-bit value into the stream.
func put_utf8_string(value: String) -> void#
Puts a zero-terminated UTF-8 string into the stream prepended by a 32 bits unsigned integer representing its size.
Note: To put a UTF-8 string without prepending its size, you can use put_data:
GDScript
put_data("Hello world".to_utf8_buffer())C#
PutData("Hello World".ToUtf8Buffer());func put_var(full_objects: bool = false) -> void#
Puts a Variant into the stream. If full_objects is true encoding objects is allowed (and can potentially include code).
Internally, this uses the same encoding mechanism as the @GlobalScope.var_to_bytes method.