summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabio Alessandrelli <fabio.alessandrelli@gmail.com>2019-05-07 10:14:52 +0200
committerGitHub <noreply@github.com>2019-05-07 10:14:52 +0200
commit0239d8bd9fa03965439aac2482d18746f807bd00 (patch)
tree89a6e88be5ee97407113c971da76353dff6ab11d
parentdf18c8c413306870871a1bf257182f2cd65016f3 (diff)
parent63d1a80656fbbacb7f055866fda7d2892721510f (diff)
Merge pull request #28453 from Tarik02/enet_socket_set_option
Partially implement enet_socket_set_option
-rw-r--r--thirdparty/enet/godot.cpp41
1 files changed, 40 insertions, 1 deletions
diff --git a/thirdparty/enet/godot.cpp b/thirdparty/enet/godot.cpp
index 2e1519b7b2..822a294781 100644
--- a/thirdparty/enet/godot.cpp
+++ b/thirdparty/enet/godot.cpp
@@ -95,7 +95,6 @@ ENetSocket enet_socket_create(ENetSocketType type) {
NetSocket *socket = NetSocket::create();
IP::Type ip_type = IP::TYPE_ANY;
socket->open(NetSocket::TYPE_UDP, ip_type);
- socket->set_blocking_enabled(false);
return socket;
}
@@ -216,6 +215,46 @@ int enet_socket_listen(ENetSocket socket, int backlog) {
int enet_socket_set_option(ENetSocket socket, ENetSocketOption option, int value) {
+ NetSocket *sock = (NetSocket *)socket;
+
+ switch (option) {
+ case ENET_SOCKOPT_NONBLOCK: {
+ sock->set_blocking_enabled(value ? false : true);
+ return 0;
+ } break;
+
+ case ENET_SOCKOPT_BROADCAST: {
+ sock->set_broadcasting_enabled(value ? true : false);
+ return 0;
+ } break;
+
+ case ENET_SOCKOPT_REUSEADDR: {
+ sock->set_reuse_address_enabled(value ? true : false);
+ return 0;
+ } break;
+
+ case ENET_SOCKOPT_RCVBUF: {
+ return -1;
+ } break;
+
+ case ENET_SOCKOPT_SNDBUF: {
+ return -1;
+ } break;
+
+ case ENET_SOCKOPT_RCVTIMEO: {
+ return -1;
+ } break;
+
+ case ENET_SOCKOPT_SNDTIMEO: {
+ return -1;
+ } break;
+
+ case ENET_SOCKOPT_NODELAY: {
+ sock->set_tcp_no_delay_enabled(value ? true : false);
+ return 0;
+ } break;
+ }
+
return -1;
}