From bb3089895c3638dd7668843099bf43d8999f0878 Mon Sep 17 00:00:00 2001 From: Tarik02 Date: Fri, 26 Apr 2019 22:23:52 +0300 Subject: Implement function enet_socket_set_option using ENetSocket class's methods. Implemented options: - ENET_SOCKOPT_NONBLOCK - ENET_SOCKOPT_BROADCAST - ENET_SOCKOPT_REUSEADDR - ENET_SOCKOPT_NODELAY Not implemented options: - ENET_SOCKOPT_RCVBUF - ENET_SOCKOPT_SNDBUF - ENET_SOCKOPT_RCVTIMEO - ENET_SOCKOPT_SNDTIMEO --- thirdparty/enet/godot.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'thirdparty/enet') diff --git a/thirdparty/enet/godot.cpp b/thirdparty/enet/godot.cpp index 2e1519b7b2..894061a20f 100644 --- a/thirdparty/enet/godot.cpp +++ b/thirdparty/enet/godot.cpp @@ -216,6 +216,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; } -- cgit v1.2.3