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
-
func bind(host: String = "*") -> intError -
func connect_to_host(port: int) -> intError -
func disconnect_from_host() -> void -
const func get_connected_host() -> String -
const func get_connected_port() -> int -
const func get_local_port() -> int -
const func get_status() -> intStreamPeerTCP.Status -
func poll() -> intError -
func set_no_delay(enabled: bool) -> void -
const STATUS_NONE = 0 enum Status -
const STATUS_CONNECTING = 1 enum Status -
const STATUS_CONNECTED = 2 enum Status -
const STATUS_ERROR = 3 enum Status -
enum Status
StreamPeerTCP #
is_refcounted, is_instantiable, core, not_builtin_classes
A stream peer that handles TCP connections.
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.
Members #
Methods #
func bind(host: String = "*") -> intError#
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 connect_to_host 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 connect_to_host(port: int) -> intError#
Connects to the specified host:port pair. A hostname will be resolved if valid. Returns OK on success.
func disconnect_from_host() -> void#
Disconnects from host.
const func get_connected_host() -> String#
Returns the IP of this peer.
const func get_connected_port() -> int#
Returns the port of this peer.
const func get_local_port() -> int#
Returns the local port to which this peer is bound.
const func get_status() -> intStreamPeerTCP.Status#
Returns the status of the connection, see Status.
func poll() -> intError#
Poll the socket, updating its state. See get_status.
func set_no_delay(enabled: bool) -> void#
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.
Annotations #
Constants #
const STATUS_NONE = 0 enum Status#
The initial status of the StreamPeerTCP. This is also the status after disconnecting.
const STATUS_CONNECTING = 1 enum Status#
A status representing a StreamPeerTCP that is connecting to a host.
const STATUS_CONNECTED = 2 enum Status#
A status representing a StreamPeerTCP that is connected to a host.
const STATUS_ERROR = 3 enum Status#
A status representing a StreamPeerTCP in error state.
Constructors #
Enums #
Status#
enum Status {
STATUS_NONE = 0,
STATUS_CONNECTING = 1,
STATUS_CONNECTED = 2,
STATUS_ERROR = 3,
}