23#include <sys/socket.h> 35 fprintf(stderr,
"Runtime type error: unix_connect expects (string path)\n");
42 int s = socket(AF_UNIX, SOCK_STREAM, 0);
44 struct sockaddr_un addr;
45 memset(&addr, 0,
sizeof(addr));
46 addr.sun_family = AF_UNIX;
47 size_t maxlen =
sizeof(addr.sun_path) - 1;
48 strncpy(addr.sun_path,
path, maxlen);
49 addr.sun_path[maxlen] =
'\0';
50 if (connect(
s, (
struct sockaddr *)&addr,
sizeof(addr)) == 0) {
push_value(vm, make_int(fd > 0 ? fd :0))
Tagged union representing a Fun value.
char * value_to_string_alloc(const Value *v)
Allocate a printable C string for a Value.
Value make_int(int64_t v)
Construct a Value representing a 64-bit integer.