ref: 552823815f7c52c16111045b638ba8bab322e7ac
parent: 690ab7aa8e6c56a4ae8a2bd5bce58d1df681234e
author: Ori Bernstein <ori@eigenstate.org>
date: Mon May 11 15:12:20 EDT 2020
add OSX recvfrom, fix UDP announce (thanks Int21h) system call to libsys for OS X and also made a minor edit to announcesock so it would work with UDP.
--- a/lib/std/listen+posixy.myr
+++ b/lib/std/listen+posixy.myr
@@ -91,8 +91,10 @@
if sys.bind(sock, sa, sz) < 0
-> `Err "failed to bind socket"
;;
- if sys.listen((sock : sys.fd), 10) < 0
- -> `Err "unable to listen on socket"
+ if proto == sys.Sockstream
+ if sys.listen((sock : sys.fd), 10) < 0
+ -> `Err "unable to listen on socket"
+ ;;
;;
-> `Ok mk([.lfd=(sock : fd)])
}
--- a/lib/sys/sys+osx-x64.myr
+++ b/lib/sys/sys+osx-x64.myr
@@ -813,6 +813,7 @@
const bind : (sock : fd, addr : sockaddr#, len : size -> int)
const setsockopt : (sock : fd, lev : sockproto, opt : sockopt, val : void#, len : size -> int)
const getsockopt : (sock : fd, lev : sockproto, opt : sockopt, val : void#, len : size# -> int)
+ const recvfrom : (sock : fd, buf : byte[:], flags : int, addr : sockaddr#, addr_len : size# -> int)
/* memory mapping */
const munmap : (addr:byte#, len:size -> int64)
@@ -1005,6 +1006,7 @@
const bind = {sock, addr, len; -> (syscall(Sysbind, a(sock), a(addr), a(len)) : int)}
const setsockopt = {sock, lev, opt, val, len; -> (syscall(Syssetsockopt, a(sock), a(lev), a(opt), a(val), a(len)) : int)}
const getsockopt = {sock, lev, opt, val, len; -> (syscall(Syssetsockopt, a(sock), a(lev), a(opt), a(val), a(len)) : int)}
+const recvfrom = {sock, buf, flags, addr, addr_len; -> (syscall(Sysrecvfrom, a(sock), (buf : byte#), a(buf.len), a(flags), a(addr), a(addr_len)) : int)}
/* memory management */
const munmap = {addr, len; -> syscall(Sysmunmap, a(addr), a(len))}