2 * \file socket.h -- declarations for socket library functions
4 * For license terms, see the file COPYING in this directory.
13 #ifdef HAVE_SYS_SOCKET_H
14 #include <sys/socket.h>
15 #elif HAVE_NET_SOCKET_H
16 #include <net/socket.h>
20 /** Create a new client socket; returns -1 on error */
21 int SockOpen(const char *host, const char *service, const char *plugin, struct addrinfo **);
25 Get a string terminated by an '\n' (matches interface of fgets).
26 Pass it a valid socket, a buffer for the string, and
27 the length of the buffer (including the trailing \0)
28 returns length of buffer on success, -1 on failure.
30 int SockRead(int sock, char *buf, int len);
33 * Peek at the next socket character without actually reading it.
35 int SockPeek(int sock);
38 Write a chunk of bytes to the socket (matches interface of fwrite).
39 Returns number of bytes successfully written.
41 int SockWrite(int sock, const char *buf, int size);
43 /* from /usr/include/sys/cdefs.h */
44 #if !defined __GNUC__ || __GNUC__ < 2
45 # define __attribute__(xyz) /* Ignore. */
49 Send formatted output to the socket (matches interface of fprintf).
50 Returns number of bytes successfully written.
52 #if defined(HAVE_STDARG_H)
53 int SockPrintf(int sock, const char *format, ...)
54 __attribute__ ((format (printf, 2, 3)))
61 Close a socket previously opened by SockOpen. This allows for some
62 additional clean-up if necessary.
64 int SockClose(int sock);
69 int UnixOpen(const char *path);
72 int SSLOpen(int sock, char *mycert, char *mykey, const char *myproto, int certck, char *cacertfile, char *cacertpath,
73 char *fingerprint, char *servercname, char *label, char **remotename);
74 #endif /* SSL_ENABLE */