From: Sapan Bhatia Date: Mon, 30 Mar 2009 14:57:09 +0000 (+0000) Subject: Client-side library for big sockets. X-Git-Url: http://git.onelab.eu/?p=vsys-wrappers.git;a=commitdiff_plain;h=7970328be9a695aecc4ecc1ea94bf686d256f1b7 Client-side library for big sockets. --- 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; +} +