Skip to content

Instantly share code, notes, and snippets.

@shichao-an
Last active August 29, 2015 14:23
Show Gist options
  • Save shichao-an/f63ebf361581af641397 to your computer and use it in GitHub Desktop.
Save shichao-an/f63ebf361581af641397 to your computer and use it in GitHub Desktop.
#include "unp.h"
int sock_bind_wild(int sockfd, int family);
/* Returns: 0 if OK, -1 on error */
int sock_cmp_addr(const struct sockaddr *sockaddr1,
const struct sockaddr *sockaddr2, socklen_t addrlen);
/* Returns: 0 if addresses are of the same family and ports are equal,
else nonzero
*/
int sock_cmp_port(const struct sockaddr *sockaddr1,
const struct sockaddr *sockaddr2, socklen_t addrlen);
/* Returns: 0 if addresses are of the same family and ports are equal,
else nonzero
*/
int sock_get_port(const struct sockaddr *sockaddr, socklen_t addrlen);
/* Returns: non-negative port number for IPv4 or IPv6 address, else -1 */
char *sock_ntop_host(const struct sockaddr *sockaddr, socklen_t addrlen);
/* Returns: non-null pointer if OK, NULL on error */
void sock_set_addr(const struct sockaddr *sockaddr, socklen_t addrlen,
void *ptr);
void sock_set_port(const struct sockaddr *sockaddr, socklen_t addrlen,
int port);
void sock_set_wild(struct sockaddr *sockaddr, socklen_t addrlen);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment