Skip to content
Snippets Groups Projects
Commit 9f4085f6 authored by Constantin P.'s avatar Constantin P. 💬 Committed by dmitriy.gerasimov
Browse files

NBIO for winsock

parent 40139374
No related branches found
No related tags found
No related merge requests found
...@@ -325,7 +325,8 @@ dap_events_socket_t * dap_events_socket_create(dap_events_desc_type_t a_type, da ...@@ -325,7 +325,8 @@ dap_events_socket_t * dap_events_socket_create(dap_events_desc_type_t a_type, da
case DESCRIPTOR_TYPE_SOCKET_LOCAL_LISTENING: case DESCRIPTOR_TYPE_SOCKET_LOCAL_LISTENING:
#ifdef DAP_OS_UNIX #ifdef DAP_OS_UNIX
l_sock_class = AF_LOCAL; l_sock_class = AF_LOCAL;
#elif DAP_OS_WIDNOWS #elif defined DAP_OS_WINDOWS
l_sock_class = AF_UNIX;
#endif #endif
break; break;
default: default:
...@@ -333,17 +334,18 @@ dap_events_socket_t * dap_events_socket_create(dap_events_desc_type_t a_type, da ...@@ -333,17 +334,18 @@ dap_events_socket_t * dap_events_socket_create(dap_events_desc_type_t a_type, da
return NULL; return NULL;
} }
#ifdef WIN32 #ifdef DAP_OS_WINDOWS
SOCKET l_sock; SOCKET l_sock = socket(l_sock_class, l_sock_type, IPPROTO_IP);
u_long l_socket_flags = 1;
if (ioctlsocket((SOCKET)l_sock, (long)FIONBIO, &l_socket_flags))
log_it(L_ERROR, "Error ioctl %d", WSAGetLastError());
#else #else
int l_sock; int l_sock = socket(l_sock_class, l_sock_type | SOCK_NONBLOCK , 0);
#endif
l_sock = socket(l_sock_class, l_sock_type | SOCK_NONBLOCK , 0);
if (l_sock == INVALID_SOCKET) { if (l_sock == INVALID_SOCKET) {
log_it(L_ERROR, "Socket create error"); log_it(L_ERROR, "Socket create error");
return NULL; return NULL;
} }
#endif
dap_events_socket_t * l_es =dap_events_socket_wrap_no_add(dap_events_get_default(),l_sock,a_callbacks); dap_events_socket_t * l_es =dap_events_socket_wrap_no_add(dap_events_get_default(),l_sock,a_callbacks);
if(!l_es){ if(!l_es){
log_it(L_CRITICAL,"Can't allocate memory for the new esocket"); log_it(L_CRITICAL,"Can't allocate memory for the new esocket");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment