2 * \file socket.h -- declarations for socket library functions
4 * For license terms, see the file COPYING in this directory.
13 #include <sys/socket.h>
16 /** Create a new client socket; returns -1 on error */
17 int SockOpen(const char *host, const char *service, const char *plugin, struct addrinfo **);
19 /** Returns 1 if socket \a fd is OK, 0 if it isn't select()able
20 * on - probably because it's been closed. You should
21 * always check this function before passing stuff to the
22 * select()-based waiter, as otherwise it may loop.
24 int SockCheckOpen(int fd);
27 Get a string terminated by an '\n' (matches interface of fgets).
28 Pass it a valid socket, a buffer for the string, and
29 the length of the buffer (including the trailing \0)
30 returns length of buffer on success, -1 on failure.
32 int SockRead(int sock, char *buf, int len);
35 * Peek at the next socket character without actually reading it.
37 int SockPeek(int sock);
40 Write a chunk of bytes to the socket (matches interface of fwrite).
41 Returns number of bytes successfully written.
43 int SockWrite(int sock, const char *buf, int size);
45 /* from /usr/include/sys/cdefs.h */
47 # define __attribute__(xyz) /* Ignore. */
51 Send formatted output to the socket (matches interface of fprintf).
52 Returns number of bytes successfully written.
54 int SockPrintf(int sock, const char *format, ...)
55 __attribute__ ((format (printf, 2, 3)))
59 Close a socket previously opened by SockOpen. This allows for some
60 additional clean-up if necessary.
62 int SockClose(int sock);
67 int UnixOpen(const char *path);
70 int SSLOpen(int sock, char *mycert, char *mykey, const char *myproto, int certck, char *cacertfile, char *cacertpath,
71 char *fingerprint, char *servercname, char *label, char **remotename);
72 #endif /* SSL_ENABLE */