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

unix: implement uv_udp_set_ttl()

  • Loading branch information...
bnoordhuis committed Jan 23, 2012
1 parent 02b41f6 commit e710fdb518bdb17335cd3f71f1f922c23234f591
Showing with 29 additions and 0 deletions.
  1. +13 −0 include/uv.h
  2. +10 −0 src/unix/udp.c
  3. +6 −0 src/win/udp.c
@@ -658,6 +658,19 @@ UV_EXTERN int uv_udp_set_multicast_ttl(uv_udp_t* handle, int ttl);
*/
UV_EXTERN int uv_udp_set_broadcast(uv_udp_t* handle, int on);

/*
* Set the time to live
*
* Arguments:
* handle UDP handle. Should have been initialized with
* `uv_udp_init`.
* ttl 1 through 255
*
* Returns:
* 0 on success, -1 on error.
*/
UV_EXTERN int uv_udp_set_ttl(uv_udp_t* handle, int ttl);

/*
* Send data. If the socket has not previously been bound with `uv_udp_bind`
* or `uv_udp_bind6`, it is bound to 0.0.0.0 (the "all interfaces" address)
@@ -528,6 +528,16 @@ int uv_udp_set_broadcast(uv_udp_t* handle, int on) {
}


int uv_udp_set_ttl(uv_udp_t* handle, int ttl) {
if (setsockopt(handle->fd, IPPROTO_IP, IP_TTL, &ttl, sizeof ttl)) {
uv__set_sys_error(handle->loop, errno);
return -1;
}

return 0;
}


int uv_udp_getsockname(uv_udp_t* handle, struct sockaddr* name,
int* namelen) {
socklen_t socklen;
@@ -599,3 +599,9 @@ int uv_udp_set_broadcast(uv_udp_t* handle, int on) {

return 0;
}


int uv_udp_set_ttl(uv_udp_t* handle, int ttl) {
uv__set_artificial_error(handle->loop, UV_ENOSYS);
return -1;
}

0 comments on commit e710fdb

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