Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

win: change uv_getsockname signature to support udp

  • Loading branch information...
piscisaureus authored and bnoordhuis committed Aug 24, 2011
1 parent 5c9d749 commit 1870c18f3c741fddae9ec3363e67f62ff0af804d
Showing with 38 additions and 2 deletions.
  1. +15 −0 src/win/handle.c
  2. +4 −1 src/win/internal.h
  3. +1 −1 src/win/tcp.c
  4. +18 −0 src/win/udp.c
@@ -39,6 +39,21 @@ int uv_is_active(uv_handle_t* handle) {
}


int uv_getsockname(uv_handle_t* handle, struct sockaddr* name, int* namelen) {
switch (handle->type) {
case UV_TCP:
return uv_tcp_getsockname((uv_tcp_t*) handle, name, namelen);

case UV_UDP:
return uv_tcp_getsockname((uv_tcp_t*) handle, name, namelen);

default:
uv_set_sys_error(WSAENOTSOCK);
return -1;
}
}


void uv_close(uv_handle_t* handle, uv_close_cb cb) {
uv_tcp_t* tcp;
uv_pipe_t* pipe;
@@ -168,6 +168,7 @@ int uv_tcp_read_start(uv_tcp_t* handle, uv_alloc_cb alloc_cb,
uv_read_cb read_cb);
int uv_tcp_write(uv_write_t* req, uv_tcp_t* handle, uv_buf_t bufs[],
int bufcnt, uv_write_cb cb);
int uv_tcp_getsockname(uv_tcp_t* handle, struct sockaddr* name, int* namelen);

void uv_process_tcp_read_req(uv_tcp_t* handle, uv_req_t* req);
void uv_process_tcp_write_req(uv_tcp_t* handle, uv_write_t* req);
@@ -180,11 +181,13 @@ void uv_tcp_endgame(uv_tcp_t* handle);
/*
* UDP
*/
void uv_udp_endgame(uv_udp_t* handle);
int uv_udp_getsockname(uv_udp_t* handle, struct sockaddr* name, int* namelen);

void uv_process_udp_recv_req(uv_udp_t* handle, uv_req_t* req);
void uv_process_udp_send_req(uv_udp_t* handle, uv_udp_send_t* req);

void uv_udp_endgame(uv_udp_t* handle);


/*
* Pipes
@@ -548,7 +548,7 @@ int uv_tcp_connect6(uv_connect_t* req, uv_tcp_t* handle,
}


int uv_getsockname(uv_handle_t* handle, struct sockaddr* name, int* namelen) {
int uv_tcp_getsockname(uv_tcp_t* handle, struct sockaddr* name, int* namelen) {
int result;

if (handle->flags & UV_HANDLE_SHUTTING) {
@@ -200,6 +200,24 @@ int uv_udp_bind6(uv_udp_t* handle, struct sockaddr_in6 addr, unsigned int flags)
}


int uv_udp_getsockname(uv_udp_t* handle, struct sockaddr* name, int* namelen) {
int result;

if (handle->flags & UV_HANDLE_SHUTTING) {
uv_set_sys_error(WSAESHUTDOWN);
return -1;
}

result = getsockname(handle->socket, name, namelen);
if (result != 0) {
uv_set_sys_error(WSAGetLastError());
return -1;
}

return 0;
}


static void uv_udp_queue_recv(uv_udp_t* handle) {
uv_req_t* req;
uv_buf_t buf;

0 comments on commit 1870c18

Please sign in to comment.
You can’t perform that action at this time.