File Descriptors

References

Select

  • On Linux, select supports a maximum of 1024 connections
  • On Windows, some historic notes suggest 64 (per thread) is the maximum, but I think this is obsolete (winsock vs winsock2)

References

Poll

References

EPoll

References

KQueue

BSD/Apple specific.

References

Compared

References


ENET

Platform Specific Functions

These functions are found to be defined in unix.c and win32.c. When porting enet to a new platform (or API), these must exist.

Init

Initialization functions. Out-of-the-box neither socket, select or poll need this, but an epoll implementation will.

  • intenet_initialize(void)
  • voidenet_deinitialize(void)

Misc

Miscaleneous functions. Primarily just time stuff.

  • enet_uint32enet_host_random_seed(void)
    • time(NULL);
  • enet_uint32enet_time_get(void)
    • gettimeofday
  • voidenet_time_set(enet_uint32 newTimeBase)
    • gettimeofday

Address

  • intenet_address_set_host_ip(ENetAddress * address, const char * name)
    • inet_pton or inet_aton
    • inet_pton is the modern function. It doesn’t autodetect, but it can be told to encode IPv6 addresses.
  • intenet_address_set_host(ENetAddress * address, const char * name)
    • getaddrinfo, freeaddrinfo, gethostbyname_r or gethostbyname
  • intenet_address_get_host_ip(const ENetAddress * address, char * name, size_t nameLength)
    • inet_ntop or inet_ntoa
    • inet_ntop is the modern function. It doesn’t autodetect, but it can be told to decode IPv6 addresses.
  • intenet_address_get_host(const ENetAddress * address, char * name, size_t nameLength)
    • getnameinfo, gethostbyaddr_r or gethostbyaddr

Socket

  • intenet_socket_bind(ENetSocket socket, const ENetAddress * address)
    • bind
  • intenet_socket_get_address(ENetSocket socket, ENetAddress * address)
    • getsockname
  • intenet_socket_listen(ENetSocket socket, int backlog)
    • listen
  • ENetSocketenet_socket_create(ENetSocketType type)
    • socket
  • intenet_socket_set_option(ENetSocket socket, ENetSocketOption option, int value)
    • fcntl or ioctl, setsockopt (many)
  • intenet_socket_get_option(ENetSocket socket, ENetSocketOption option, int * value)
    • getsockopt
  • intenet_socket_connect(ENetSocket socket, const ENetAddress * address)
    • connect
  • ENetSocketenet_socket_accept(ENetSocket socket, ENetAddress * address)
    • accept
  • intenet_socket_shutdown(ENetSocket socket, ENetSocketShutdown how)
    • shutdown
  • voidenet_socket_destroy(ENetSocket socket)
    • close
  • intenet_socket_send(ENetSocket socket, const ENetAddress * address, const ENetBuffer * buffers, size_t bufferCount)
    • sendmsg
  • intenet_socket_receive(ENetSocket socket, ENetAddress * address, ENetBuffer * buffers, size_t bufferCount)
    • recvmsg
  • intenet_socketset_select(ENetSocket maxSocket, ENetSocketSet * readSet, ENetSocketSet * writeSet, enet_uint32 timeout)
    • select
  • intenet_socket_wait(ENetSocket socket, enet_uint32 * condition, enet_uint32 timeout)
    • poll or select