Пример #1
0
int uv_tcp_bind(uv_tcp_t* handle, struct sockaddr_in addr) {
  if (handle->type != UV_TCP || addr.sin_family != AF_INET) {
    uv__set_artificial_error(handle->loop, UV_EFAULT);
    return -1;
  }

  return uv__tcp_bind(handle, addr);
}
Пример #2
0
int uv_tcp_bind6(uv_tcp_t* tcp, struct sockaddr_in6 addr) {
  if (addr.sin6_family != AF_INET6) {
    uv_err_new(tcp->loop, EFAULT);
    return -1;
  }

  return uv__tcp_bind(tcp,
                      AF_INET6,
                      (struct sockaddr*)&addr,
                      sizeof(struct sockaddr_in6));
}
Пример #3
0
int uv_tcp_bind(uv_tcp_t* handle,
                const struct sockaddr* addr,
                unsigned int flags) {
  unsigned int addrlen;

  if (handle->type != UV_TCP)
    return UV_EINVAL;

  if (addr->sa_family == AF_INET)
    addrlen = sizeof(struct sockaddr_in);
  else if (addr->sa_family == AF_INET6)
    addrlen = sizeof(struct sockaddr_in6);
  else
    return UV_EINVAL;

  return uv__tcp_bind(handle, addr, addrlen, flags);
}
Пример #4
0
int uv_tcp_bind(uv_tcp_t* handle, struct sockaddr_in addr) {
  if (handle->type != UV_TCP || addr.sin_family != AF_INET)
    return UV_EINVAL;
  else
    return uv__tcp_bind(handle, addr);
}
Пример #5
0
int uv_tcp_bind6(uv_tcp_t* handle, const struct sockaddr_in6* addr) {
  if (handle->type == UV_TCP && addr->sin6_family == AF_INET6)
    return uv__tcp_bind(handle, (const struct sockaddr*) addr, sizeof(*addr));
  else
    return UV_EINVAL;
}