From 9536b0affa0cbbe5d69ee8868c6dad12ddd05f0b Mon Sep 17 00:00:00 2001 From: Quentin Date: Thu, 9 Jul 2020 09:55:45 +0200 Subject: [PATCH] socket binding ok --- bindings/libc.scm | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/bindings/libc.scm b/bindings/libc.scm index 27439f8..18d3103 100644 --- a/bindings/libc.scm +++ b/bindings/libc.scm @@ -1,2 +1,33 @@ (load-shared-object "libc.so.6") +(define (domain-flag->int flag) + (case flag + ((AF_INET) 2) +)) + +(define (type-flag->int flag) + (case flag + ((SOCK_DGRAM) 2) + ((SOCK_DCCP) 6) +)) + +(define (protocol-flag->int flag) + (case flag + ((IPPROTO_NONE) 0) + ((IPPROTO_DCCP) 33) +)) + +(define (perror str) + ((foreign-procedure + "perror" + (string) + void) str)) + +(define (socket domain type protocol) + ((foreign-procedure + "socket" + (int int int) + int) + (domain-flag->int domain) + (type-flag->int type) + (protocol-flag->int protocol)))