mirror of
https://github.com/godotengine/godot.git
synced 2026-01-06 10:11:57 +03:00
Core: Add UNIX domain socket support
> [!NOTE] > > Later versions of Windows has support for `AF_UNIX`, so it could be > added.
This commit is contained in:
@@ -2377,6 +2377,9 @@
|
||||
<member name="network/limits/tcp/connect_timeout_seconds" type="int" setter="" getter="" default="30">
|
||||
Timeout (in seconds) for connection attempts using TCP.
|
||||
</member>
|
||||
<member name="network/limits/unix/connect_timeout_seconds" type="int" setter="" getter="" default="30">
|
||||
Timeout (in seconds) for connection attempts using UNIX domain socket.
|
||||
</member>
|
||||
<member name="network/limits/webrtc/max_channel_in_buffer_kb" type="int" setter="" getter="" default="64">
|
||||
Maximum size (in kiB) for the [WebRTCDataChannel] input buffer.
|
||||
</member>
|
||||
|
||||
37
doc/classes/SocketServer.xml
Normal file
37
doc/classes/SocketServer.xml
Normal file
@@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="SocketServer" inherits="RefCounted" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
|
||||
<brief_description>
|
||||
An abstract class for servers based on sockets.
|
||||
</brief_description>
|
||||
<description>
|
||||
A socket server.
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
<method name="is_connection_available" qualifiers="const">
|
||||
<return type="bool" />
|
||||
<description>
|
||||
Returns [code]true[/code] if a connection is available for taking.
|
||||
</description>
|
||||
</method>
|
||||
<method name="is_listening" qualifiers="const">
|
||||
<return type="bool" />
|
||||
<description>
|
||||
Returns [code]true[/code] if the server is currently listening for connections.
|
||||
</description>
|
||||
</method>
|
||||
<method name="stop">
|
||||
<return type="void" />
|
||||
<description>
|
||||
Stops listening.
|
||||
</description>
|
||||
</method>
|
||||
<method name="take_socket_connection">
|
||||
<return type="StreamPeerSocket" />
|
||||
<description>
|
||||
If a connection is available, returns a StreamPeerSocket with the connection.
|
||||
</description>
|
||||
</method>
|
||||
</methods>
|
||||
</class>
|
||||
45
doc/classes/StreamPeerSocket.xml
Normal file
45
doc/classes/StreamPeerSocket.xml
Normal file
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="StreamPeerSocket" inherits="StreamPeer" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
|
||||
<brief_description>
|
||||
Abstract base class for interacting with socket streams.
|
||||
</brief_description>
|
||||
<description>
|
||||
StreamPeerSocket is an abstract base class that defines common behavior for socket-based streams.
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
<method name="disconnect_from_host">
|
||||
<return type="void" />
|
||||
<description>
|
||||
Disconnects from host.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_status" qualifiers="const">
|
||||
<return type="int" enum="StreamPeerSocket.Status" />
|
||||
<description>
|
||||
Returns the status of the connection.
|
||||
</description>
|
||||
</method>
|
||||
<method name="poll">
|
||||
<return type="int" enum="Error" />
|
||||
<description>
|
||||
Polls the socket, updating its state. See [method get_status].
|
||||
</description>
|
||||
</method>
|
||||
</methods>
|
||||
<constants>
|
||||
<constant name="STATUS_NONE" value="0" enum="Status">
|
||||
The initial status of the [StreamPeerSocket]. This is also the status after disconnecting.
|
||||
</constant>
|
||||
<constant name="STATUS_CONNECTING" value="1" enum="Status">
|
||||
A status representing a [StreamPeerSocket] that is connecting to a host.
|
||||
</constant>
|
||||
<constant name="STATUS_CONNECTED" value="2" enum="Status">
|
||||
A status representing a [StreamPeerSocket] that is connected to a host.
|
||||
</constant>
|
||||
<constant name="STATUS_ERROR" value="3" enum="Status">
|
||||
A status representing a [StreamPeerSocket] in error state.
|
||||
</constant>
|
||||
</constants>
|
||||
</class>
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="StreamPeerTCP" inherits="StreamPeer" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
|
||||
<class name="StreamPeerTCP" inherits="StreamPeerSocket" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
|
||||
<brief_description>
|
||||
A stream peer that handles TCP connections.
|
||||
</brief_description>
|
||||
@@ -27,12 +27,6 @@
|
||||
Connects to the specified [code]host:port[/code] pair. A hostname will be resolved if valid. Returns [constant OK] on success.
|
||||
</description>
|
||||
</method>
|
||||
<method name="disconnect_from_host">
|
||||
<return type="void" />
|
||||
<description>
|
||||
Disconnects from host.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_connected_host" qualifiers="const">
|
||||
<return type="String" />
|
||||
<description>
|
||||
@@ -51,18 +45,6 @@
|
||||
Returns the local port to which this peer is bound.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_status" qualifiers="const">
|
||||
<return type="int" enum="StreamPeerTCP.Status" />
|
||||
<description>
|
||||
Returns the status of the connection.
|
||||
</description>
|
||||
</method>
|
||||
<method name="poll">
|
||||
<return type="int" enum="Error" />
|
||||
<description>
|
||||
Poll the socket, updating its state. See [method get_status].
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_no_delay">
|
||||
<return type="void" />
|
||||
<param index="0" name="enabled" type="bool" />
|
||||
@@ -72,18 +54,4 @@
|
||||
</description>
|
||||
</method>
|
||||
</methods>
|
||||
<constants>
|
||||
<constant name="STATUS_NONE" value="0" enum="Status">
|
||||
The initial status of the [StreamPeerTCP]. This is also the status after disconnecting.
|
||||
</constant>
|
||||
<constant name="STATUS_CONNECTING" value="1" enum="Status">
|
||||
A status representing a [StreamPeerTCP] that is connecting to a host.
|
||||
</constant>
|
||||
<constant name="STATUS_CONNECTED" value="2" enum="Status">
|
||||
A status representing a [StreamPeerTCP] that is connected to a host.
|
||||
</constant>
|
||||
<constant name="STATUS_ERROR" value="3" enum="Status">
|
||||
A status representing a [StreamPeerTCP] in error state.
|
||||
</constant>
|
||||
</constants>
|
||||
</class>
|
||||
|
||||
35
doc/classes/StreamPeerUDS.xml
Normal file
35
doc/classes/StreamPeerUDS.xml
Normal file
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="StreamPeerUDS" inherits="StreamPeerSocket" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
|
||||
<brief_description>
|
||||
A stream peer that handles UNIX Domain Socket (UDS) connections.
|
||||
</brief_description>
|
||||
<description>
|
||||
A stream peer that handles UNIX Domain Socket (UDS) connections. This object can be used to connect to UDS servers, or also is returned by a UDS server. Unix Domain Sockets provide inter-process communication on the same machine using the filesystem namespace.
|
||||
[b]Note:[/b] UNIX Domain Sockets are only available on UNIX-like systems (Linux, macOS, etc.) and are not supported on Windows.
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
<method name="bind">
|
||||
<return type="int" enum="Error" />
|
||||
<param index="0" name="path" type="String" />
|
||||
<description>
|
||||
Opens the UDS socket, and binds it to the specified socket path.
|
||||
This method is generally not needed, and only used to force the subsequent call to [method connect_to_host] to use the specified [param path] as the source address.
|
||||
</description>
|
||||
</method>
|
||||
<method name="connect_to_host">
|
||||
<return type="int" enum="Error" />
|
||||
<param index="0" name="path" type="String" />
|
||||
<description>
|
||||
Connects to the specified UNIX Domain Socket path. Returns [constant OK] on success.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_connected_path" qualifiers="const">
|
||||
<return type="String" />
|
||||
<description>
|
||||
Returns the socket path of this peer.
|
||||
</description>
|
||||
</method>
|
||||
</methods>
|
||||
</class>
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="TCPServer" inherits="RefCounted" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
|
||||
<class name="TCPServer" inherits="SocketServer" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
|
||||
<brief_description>
|
||||
A TCP server.
|
||||
</brief_description>
|
||||
@@ -16,18 +16,6 @@
|
||||
Returns the local port this server is listening to.
|
||||
</description>
|
||||
</method>
|
||||
<method name="is_connection_available" qualifiers="const">
|
||||
<return type="bool" />
|
||||
<description>
|
||||
Returns [code]true[/code] if a connection is available for taking.
|
||||
</description>
|
||||
</method>
|
||||
<method name="is_listening" qualifiers="const">
|
||||
<return type="bool" />
|
||||
<description>
|
||||
Returns [code]true[/code] if the server is currently listening for connections.
|
||||
</description>
|
||||
</method>
|
||||
<method name="listen">
|
||||
<return type="int" enum="Error" />
|
||||
<param index="0" name="port" type="int" />
|
||||
@@ -39,12 +27,6 @@
|
||||
If [param bind_address] is set to any valid address (e.g. [code]"192.168.1.101"[/code], [code]"::1"[/code], etc.), the server will only listen on the interface with that address (or fail if no interface with the given address exists).
|
||||
</description>
|
||||
</method>
|
||||
<method name="stop">
|
||||
<return type="void" />
|
||||
<description>
|
||||
Stops listening.
|
||||
</description>
|
||||
</method>
|
||||
<method name="take_connection">
|
||||
<return type="StreamPeerTCP" />
|
||||
<description>
|
||||
|
||||
28
doc/classes/UDSServer.xml
Normal file
28
doc/classes/UDSServer.xml
Normal file
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="UDSServer" inherits="SocketServer" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
|
||||
<brief_description>
|
||||
A Unix Domain Socket (UDS) server.
|
||||
</brief_description>
|
||||
<description>
|
||||
A Unix Domain Socket (UDS) server. Listens to connections on a socket path and returns a [StreamPeerUDS] when it gets an incoming connection. Unix Domain Sockets provide inter-process communication on the same machine using the filesystem namespace.
|
||||
[b]Note:[/b] Unix Domain Sockets are only available on Unix-like systems (Linux, macOS, etc.) and are not supported on Windows.
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
<method name="listen">
|
||||
<return type="int" enum="Error" />
|
||||
<param index="0" name="path" type="String" />
|
||||
<description>
|
||||
Listens on the socket at [param path]. The socket file will be created at the specified path.
|
||||
[b]Note:[/b] The socket file must not already exist at the specified path. You may need to remove any existing socket file before calling this method.
|
||||
</description>
|
||||
</method>
|
||||
<method name="take_connection">
|
||||
<return type="StreamPeerUDS" />
|
||||
<description>
|
||||
If a connection is available, returns a StreamPeerUDS with the connection.
|
||||
</description>
|
||||
</method>
|
||||
</methods>
|
||||
</class>
|
||||
Reference in New Issue
Block a user