Tizen Sockets Extension API References

This topic lists methods provided by the Tizen Sockets Extension for WebAssembly.


Related Info


When possible, the semantics of these functions conform to the POSIX.1-2017 standard. The most notable differences are:

  • lack of signals support in Emscripten and in a web environment.
  • Tizen Sockets Extension APIs cannot be called from the main thread, which is usually the one running the main function unless -s PROXY_TO_PTHREAD or --proxy-to-worker flags are provided to Emscripten during link time. See Additional flags in the Emscripten documentation.
  • Socket functions that accept multiple descriptors can accept only one descriptor type at a time. Descriptor types cannot be mixed (meaning that a method can be called with either socket descriptors or file descriptors, but not both). In particular, this applies to poll() and select() methods.
  • select() method can be slow due to its internal implementation in Emscripten. It is recommended to use poll() method instead.

The following extensions to sockets are provided:

Method
Argument Value
Reference
accept()

-
accept4()

Values in flags:
  • SOCK_NONBLOCK
  • SOCK_CLOEXEC

bind()

-
close()

-
connect()

-
freeaddrinfo()

-
getaddrinfo()

-
gethostbyaddr()

-
gethostbyname()

-
getpeername()

-
getsockname()

-
getsockopt()

Combinations of level and optname:
  • SOL_SOCKET, SO_DEBUG
  • SOL_SOCKET, SO_ERROR
  • SOL_SOCKET, SO_BROADCAST
  • SOL_SOCKET, SO_REUSEADDR
  • SOL_SOCKET, SO_KEEPALIVE
  • SOL_SOCKET, SO_OOBINLINE
  • SOL_SOCKET, SO_SNDBUF
  • SOL_SOCKET, SO_RCVBUF
  • SOL_SOCKET, SO_DONTROUTE
  • SOL_SOCKET, SO_RCVLOWAT
  • SOL_SOCKET, SO_SNDLOWAT
  • SOL_SOCKET, SO_RCVTIMEO
  • SOL_SOCKET, SO_SNDTIMEO
  • SOL_SOCKET, SO_LINGER
  • IPPROTO_TCP, TCP_NODELAY
  • IPPROTO_IP, IP_MULTICAST_LOOP
  • IPPROTO_IP, IP_MULTICAST_TTL
  • IPPROTO_IPV6, IPV6_MULTICAST_HOPS
  • IPPROTO_IPV6, IPV6_MULTICAST_LOOP

listen()

-
poll()

Supported event flags:
  • POLLIN
  • POLLRDNORM
  • POLLRDBAND
  • POLLPRI
  • POLLOUT
  • POLLWRNORM
  • POLLWRBAND
  • POLLERR
  • POLLHUP
  • POLLNVAL

Usage notes:
  • The Tizen Sockets Extension for WebAssembly does not support mixing descriptor types in poll() calls. An application must use only one type of descriptors each time it calls poll() (to pass either socket descriptors or file descriptors as arguments of a single call, never both).
  • It is recommended to use poll() over select(), because the internalselect() implementation in the Samsung Emscripten SDK can be slow.

read()

-
recv()

Values in flags:
  • MSG_PEEK
  • MSG_OOB
  • MSG_WAITALL

recvfrom()

Values in flags:
  • MSG_PEEK
  • MSG_OOB
  • MSG_WAITALL

recvmsg()

Values in flags:
  • MSG_PEEK
  • MSG_OOB
  • MSG_WAITALL

select()

Usage notes:
  • TThe Tizen Sockets Extension for WebAssembly does not support mixing descriptor types in select() calls. An application must use only one type of descriptors each time it calls select() (to pass either socket descriptors or file descriptors as arguments of a single call, never both).
  • The select() method can be slow due to its internal implementation in the Samsung Emscripten SDK. It is recommended to use poll() instead.

send()

Values in flags:
  • MSG_EOR
  • MSG_OOB
  • MSG_NOSIGNAL

The Open Group Base Specifications Issue 7, 2018 edition - send

sendmsg()

Values in flags:
  • MSG_EOR
  • MSG_OOB
  • MSG_NOSIGNAL

sendto()

Values in flags:
  • MSG_EOR
  • MSG_OOB
  • MSG_NOSIGNAL

setsockopt()

Combinations of level and optname:
  • SOL_SOCKET, SO_DEBUG,
  • SOL_SOCKET, SO_BROADCAST
  • SOL_SOCKET, SO_REUSEADDR
  • SOL_SOCKET, SO_KEEPALIVE
  • SOL_SOCKET, SO_OOBINLINE
  • SOL_SOCKET, SO_SNDBUF
  • SOL_SOCKET, SO_RCVBUF
  • SOL_SOCKET, SO_DONTROUTE
  • SOL_SOCKET, SO_RCVLOWAT
  • SOL_SOCKET, SO_SNDLOWAT
  • SOL_SOCKET, SO_RCVTIMEO
  • SOL_SOCKET, SO_SNDTIMEO
  • SOL_SOCKET, SO_LINGER
  • IPPROTO_TCP, TCP_NODELAY
  • IPPROTO_IP, IP_MULTICAST_LOOP
  • IPPROTO_IP, IP_MULTICAST_TTL
  • IPPROTO_IP, IP_ADD_MEMBERSHIP
  • IPPROTO_IP, IP_ADD_SOURCE_MEMBERSHIP
  • IPPROTO_IP, IP_BLOCK_SOURCE
  • IPPROTO_IP, IP_DROP_MEMBERSHIP
  • IPPROTO_IP, IP_DROP_SOURCE_MEMBERSHIP
  • IPPROTO_IP, IP_UNBLOCK_SOURCE
  • IPPROTO_IPV6, IPV6_MULTICAST_HOPS
  • IPPROTO_IPV6, IPV6_MULTICAST_LOOP
  • IPPROTO_IPV6, IPV6_JOIN_GROUP
  • IPPROTO_IPV6, IPV6_LEAVE_GROUP

shutdown()

Values in how:
  • SHUT_RD
  • SHUT_WR
  • SHUT_RDWR

socket()

Values in domain:
  • AF_INET
  • AF_INET6

Values in type:
  • SOCK_STREAM
  • SOCK_DGRAM

Flags bitwise ORed with type argument:
  • SOCK_CLOEXEC
  • SOCK_NONBLOCK

write()

-

Table 1: Tizen Sockets Extension Methods