+
+ # Set whether this socket is non blocking
+ fun non_blocking=(value: Bool) `{
+ int flags = fcntl(*self, F_GETFL, 0);
+ if (flags == -1) flags = 0;
+
+ if (value) {
+ flags = flags | O_NONBLOCK;
+ } else if (flags & O_NONBLOCK) {
+ flags = flags - O_NONBLOCK;
+ } else {
+ return;
+ }
+ fcntl(*self, F_SETFL, flags);
+ `}
+
+ # Send `len` bytes from `buf` to `dest_addr`
+ fun sendto(buf: CString, len: Int, flags: Int, dest_addr: NativeSocketAddrIn): Int `{
+ return sendto(*self, buf, len, flags, (struct sockaddr*)dest_addr, sizeof(struct sockaddr_in));
+ `}
+
+ # Receive a message into `buf` of maximum `len` bytes
+ fun recv(buf: CString, len: Int, flags: Int): Int `{
+ return recv(*self, buf, len, flags);
+ `}
+
+ # Receive a message into `buf` of maximum `len` bytes and store sender info into `src_addr`
+ fun recvfrom(buf: CString, len: Int, flags: Int, src_addr: NativeSocketAddrIn): Int `{
+ socklen_t srclen = sizeof(struct sockaddr_in);
+ return recvfrom(*self, buf, len, flags, (struct sockaddr*)src_addr, &srclen);
+ `}