diff --git a/src/os/portable/os-impl-bsd-sockets.c b/src/os/portable/os-impl-bsd-sockets.c index 59bc5d26a..b02b1b3f6 100644 --- a/src/os/portable/os-impl-bsd-sockets.c +++ b/src/os/portable/os-impl-bsd-sockets.c @@ -102,10 +102,13 @@ int32 OS_SocketOpen_Impl(const OS_object_token_t *token) switch (stream->socket_type) { case OS_SocketType_DATAGRAM: - os_type = SOCK_DGRAM; + os_type = SOCK_DGRAM; + os_proto = IPPROTO_UDP; break; + case OS_SocketType_STREAM: - os_type = SOCK_STREAM; + os_type = SOCK_STREAM; + os_proto = IPPROTO_TCP; break; default: @@ -126,17 +129,6 @@ int32 OS_SocketOpen_Impl(const OS_object_token_t *token) return OS_ERR_NOT_IMPLEMENTED; } - /* Only AF_INET* at this point, can add cases if support is expanded */ - switch (stream->socket_type) - { - case OS_SocketType_DATAGRAM: - os_proto = IPPROTO_UDP; - break; - case OS_SocketType_STREAM: - os_proto = IPPROTO_TCP; - break; - } - impl->fd = socket(os_domain, os_type, os_proto); if (impl->fd < 0) {