Beispiel #1
0
// Opens an IPv4 UDP socket. Returns 1 if successful.
static int ioOpenUDPv4Socket(struct s_io_state *iostate, const char *bindaddress, const char *bindport, const int sockmark) {
	int fd;
	if(ioOpenSocket(&fd, bindaddress, bindport, AF_INET, SOCK_DGRAM, 0, sockmark)) {
		iostate->fd[IO_FDID_UDPV4SOCKET].fd = fd;
#ifdef IO_WINDOWS
#else
		iostate->fd[IO_FDID_UDPV4SOCKET].events = POLLIN;
#endif
		return 1;
	}
	else {
		return 0;
	}
}
Beispiel #2
0
// Opens an IPv6 UDP socket. Returns 1 if successful.
static int ioOpenUDPv6Socket(struct s_io_state *iostate, const char *bindaddress, const char *bindport, const int sockmark) {
#ifdef IO_WINDOWS
	return 0; // not implemented
#else
	int fd;
	if(ioOpenSocket(&fd, bindaddress, bindport, AF_INET6, SOCK_DGRAM, 0, sockmark)) {
		iostate->fd[IO_FDID_UDPV6SOCKET].fd = fd;
		iostate->fd[IO_FDID_UDPV6SOCKET].events = POLLIN;
		return 1;
	}
	else {
		return 0;
	}
#endif
}
Beispiel #3
0
// Opens an IPv4 UDP socket. Returns handle ID if successful, or -1 on error.
int ioOpenSocketV4(struct s_io_state *iostate, const char *bindaddress, const char *bindport) {
	return ioOpenSocket(iostate, IO_TYPE_SOCKET_V4, bindaddress, bindport, AF_INET, SOCK_DGRAM, 0);
}