/** * @file kavsockets.h * @author Claudiu Dragalina-Paraipan */ #ifndef __KAVSOCKETS_H_INCLUDED #define __KAVSOCKETS_H_INCLUDED /// @name Socket type /// @{ #define KAV_SOCK_INET 1 #define KAV_SOCK_UNIX 2 /// @} /** * @brief Connects to specified destination * @param[in] sock Destination specification * @param[out] sockFamily Socket type * @return Descriptor referencing the socket in case of success, * or -1 in case of error */ int kavSocketConnect(const char *sock, int *sockFamily); /** * @brief Closes an open socket * @param[in] fd Socket to close */ void kavSocketClose(int fd); /** * @brief Writes data to socket * @param[in] fd Socket to write to * @param[in] buf Buffer to write * @param[in] size Buffer size * @return Total amount of written data in case of success, -1 in case of failure. * * Entire buffer is written. */ int kavSocketWrite(int fd, const void *buf, unsigned int size); /** * @brief Reads data from socket * @param[in] fd Socket to read from * @param[in] buf Buffer to read into * @param[in] size Size of data to read * @return Total amount of data data in case of success, -1 in case of failure. * * It only returns after reading the specified size. */ int kavSocketRead(int fd, void *buf, unsigned int size); #ifdef __KAVSOCKETS_C static int kavSocketConnectInet(const char *dest, unsigned short port); static int kavSocketConnectUnix(const char *dest); static int parseDestination(const char *dest, char **address); #endif #endif // __KAVSOCKETS_H_INCLUDED