From 7970328be9a695aecc4ecc1ea94bf686d256f1b7 Mon Sep 17 00:00:00 2001 From: Sapan Bhatia Date: Mon, 30 Mar 2009 14:57:09 +0000 Subject: [PATCH] Client-side library for big sockets. --- bmsocket/bmsocket.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 bmsocket/bmsocket.c diff --git a/bmsocket/bmsocket.c b/bmsocket/bmsocket.c new file mode 100644 index 0000000..873f4fc --- /dev/null +++ b/bmsocket/bmsocket.c @@ -0,0 +1,38 @@ +#include +#include +#include +#include +#include +#include "fdpass.h" + +#define VSYS_BMSOCKET "/vsys/fd_bmsocket.control" + +int socket(int domain, int type, int protocol) +{ + int sfd; + struct sockaddr_un addr; + int remotefd; + + sfd = socket(AF_UNIX, SOCK_STREAM, 0); + if (sfd == -1) { + perror("Could not create UNIX socket\n"); + exit(-1); + } + + memset(&addr, 0, sizeof(struct sockaddr_un)); + /* Clear structure */ + addr.sun_family = AF_UNIX; + strncpy(addr.sun_path, VSYS_BMSOCKET, + sizeof(addr.sun_path) - 1); + + if (connect(sfd, (struct sockaddr *) &addr, + sizeof(struct sockaddr_un)) == -1) { + perror("Could not connect to Vsys control socket"); + exit(-1); + } + + + remotefd = receive_fd(sfd); + return remotefd; +} + -- 2.43.0