Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
godot
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
community
godot
Commits
c13be795
Commit
c13be795
authored
Jun 30, 2019
by
Fabio Alessandrelli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add TCP Server is_listening method
parent
24c52f1c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
0 deletions
+15
-0
tcp_server.cpp
core/io/tcp_server.cpp
+7
-0
tcp_server.h
core/io/tcp_server.h
+1
-0
TCP_Server.xml
doc/classes/TCP_Server.xml
+7
-0
No files found.
core/io/tcp_server.cpp
View file @
c13be795
...
...
@@ -34,6 +34,7 @@ void TCP_Server::_bind_methods() {
ClassDB
::
bind_method
(
D_METHOD
(
"listen"
,
"port"
,
"bind_address"
),
&
TCP_Server
::
listen
,
DEFVAL
(
"*"
));
ClassDB
::
bind_method
(
D_METHOD
(
"is_connection_available"
),
&
TCP_Server
::
is_connection_available
);
ClassDB
::
bind_method
(
D_METHOD
(
"is_listening"
),
&
TCP_Server
::
is_listening
);
ClassDB
::
bind_method
(
D_METHOD
(
"take_connection"
),
&
TCP_Server
::
take_connection
);
ClassDB
::
bind_method
(
D_METHOD
(
"stop"
),
&
TCP_Server
::
stop
);
}
...
...
@@ -75,6 +76,12 @@ Error TCP_Server::listen(uint16_t p_port, const IP_Address &p_bind_address) {
return
OK
;
}
bool
TCP_Server
::
is_listening
()
const
{
ERR_FAIL_COND_V
(
!
_sock
.
is_valid
(),
false
);
return
_sock
->
is_open
();
}
bool
TCP_Server
::
is_connection_available
()
const
{
ERR_FAIL_COND_V
(
!
_sock
.
is_valid
(),
false
);
...
...
core/io/tcp_server.h
View file @
c13be795
...
...
@@ -50,6 +50,7 @@ protected:
public
:
Error
listen
(
uint16_t
p_port
,
const
IP_Address
&
p_bind_address
=
IP_Address
(
"*"
));
bool
is_listening
()
const
;
bool
is_connection_available
()
const
;
Ref
<
StreamPeerTCP
>
take_connection
();
...
...
doc/classes/TCP_Server.xml
View file @
c13be795
...
...
@@ -16,6 +16,13 @@
Returns [code]true[/code] if a connection is available for taking.
</description>
</method>
<method
name=
"is_listening"
qualifiers=
"const"
>
<return
type=
"bool"
>
</return>
<description>
Returns [code]true[/code] if the server is currently listening for connections.
</description>
</method>
<method
name=
"listen"
>
<return
type=
"int"
enum=
"Error"
>
</return>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment