summaryrefslogtreecommitdiffstats
path: root/otherlibs/unix/getsockname.c
diff options
context:
space:
mode:
Diffstat (limited to 'otherlibs/unix/getsockname.c')
-rw-r--r--otherlibs/unix/getsockname.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/otherlibs/unix/getsockname.c b/otherlibs/unix/getsockname.c
new file mode 100644
index 000000000..40cc1a663
--- /dev/null
+++ b/otherlibs/unix/getsockname.c
@@ -0,0 +1,23 @@
+#include <mlvalues.h>
+#include "unix.h"
+
+#ifdef HAS_SOCKETS
+
+#include "socketaddr.h"
+
+value unix_getsockname(sock) /* ML */
+ value sock;
+{
+ int retcode;
+
+ sock_addr_len = sizeof(sock_addr);
+ retcode = getsockname(Int_val(sock), &sock_addr.s_gen, &sock_addr_len);
+ if (retcode == -1) uerror("getsockname", Nothing);
+ return alloc_sockaddr();
+}
+
+#else
+
+value unix_getsockname() { invalid_argument("getsockname not implemented"); }
+
+#endif