#ifndef SOCK_H
#define SOCK_H
/*
* Low-level socket-related functions
*/
#include <sys/types.h>
/*
* The generic socket handle
*/
struct sock_stream;
/*
* A simple blocking TCP connect to the given host/service, using getaddrinfo.
*
* XXX: blocking
* XXX: exits on error
*
* Returns the socket handle.
*/
struct sock_stream *sock_tcp_connect (const char *host, const char *service);
/*
* A simple blocking SSL connect to the given host/service.
*
* XXX: blocking
* XXX: doesn't do any certificate verification.
* XXX: exits on error
*
* Returns the socket handle.
*/
struct sock_stream *sock_ssl_connect (const char *host, const char *service);
/*
* Initialize the socket module's global state
*/
void sock_init (void);
/*
* The generic read/write API for stream sockets.
*/
int sock_stream_read (struct sock_stream *sock, void *buf, size_t len);
int sock_stream_write (struct sock_stream *sock, const void *buf, size_t len);
#endif