#include "nanohttp-error.h"
#include "nanohttp-logging.h"
#include "nanohttp-common.h"
#include "nanohttp-socket.h"
Go to the source code of this file.
Defines | |
#define | HSOCKET_FREE -1 |
Functions | |
herror_t | hsocket_module_init (int argc, char **argv) |
void | hsocket_module_destroy (void) |
herror_t | hsocket_init (struct hsocket_t *sock) |
void | hsocket_free (struct hsocket_t *sock) |
herror_t | hsocket_open (struct hsocket_t *dsock, const char *hostname, int port, int ssl) |
herror_t | hsocket_bind (struct hsocket_t *dsock, unsigned short port) |
herror_t | hsocket_accept (struct hsocket_t *sock, struct hsocket_t *dest) |
herror_t | hsocket_listen (struct hsocket_t *sock) |
void | hsocket_close (struct hsocket_t *sock) |
herror_t | hsocket_send (struct hsocket_t *sock, const unsigned char *bytes, int n) |
herror_t | hsocket_send_string (struct hsocket_t *sock, const char *str) |
int | hsocket_select_recv (int sock, char *buf, size_t len) |
herror_t | hsocket_recv (struct hsocket_t *sock, unsigned char *buffer, int total, int force, int *received) |
int | hsocket_get_timeout (void) |
void | hsocket_set_timeout (int secs) |
|
Definition at line 98 of file nanohttp-socket.c. Referenced by hsocket_init(). |
|
Accepts an incoming socket request. Note that this function will not return until a socket connection is ready.
Definition at line 324 of file nanohttp-socket.c. References hsocket_t::addr, H_OK, herror_message(), herror_new(), HSOCKET_ERROR_NOT_INITIALIZED, hssl_server_ssl(), log_verbose3, log_warn2, SAVE_STR, and hsocket_t::sock. Referenced by httpd_run(). |
|
Binds a socket to a given port number. After bind you can call hsocket_listen() to listen to the port.
Definition at line 292 of file nanohttp-socket.c. References H_OK, herror_new(), HSOCKET_ERROR_BIND, HSOCKET_ERROR_CREATE, log_error2, and hsocket_t::sock. Referenced by httpd_init(). |
|
e Close a socket connection.
Definition at line 368 of file nanohttp-socket.c. References hsocket_t::bytes_received, hsocket_t::bytes_transmitted, hssl_cleanup(), log_verbose1, log_verbose3, and hsocket_t::sock. Referenced by httpc_close_free(), and httpd_run(). |
|
Destroys and releases a given socket.
Definition at line 238 of file nanohttp-socket.c. Referenced by httpc_free(). |
|
Get the socket read/write timeout.
Definition at line 501 of file nanohttp-socket.c. Referenced by httpd_get_timeout(). |
|
Initializes a given socket object. This function (or hsokcet_init_ssl) should be called for every socket before using it.
Definition at line 229 of file nanohttp-socket.c. References H_OK, HSOCKET_FREE, and hsocket_t::sock. Referenced by httpc_new(), and httpd_init(). |
|
Set the socket to the listen mode. You must bind the socket to a port with hsocket_bind() before you can listen to the port.
Definition at line 351 of file nanohttp-socket.c. References H_OK, herror_new(), HSOCKET_ERROR_LISTEN, HSOCKET_ERROR_NOT_INITIALIZED, log_error2, and hsocket_t::sock. Referenced by httpd_run(). |
|
Destroys the socket modul. This should be called after finishing an application.
Definition at line 221 of file nanohttp-socket.c. Referenced by httpc_destroy(), and httpd_destroy(). |
|
Initializes the socket modul. This should be called only once for an application.
Definition at line 201 of file nanohttp-socket.c. References H_OK, herror_message(), hssl_module_init(), and log_error2. Referenced by httpc_init(), and httpd_init(). |
|
Connects to a given host. The hostname can be an IP number or a humen readable hostname.
Definition at line 246 of file nanohttp-socket.c. References H_OK, herror_message(), herror_new(), HSOCKET_ERROR_CONNECT, HSOCKET_ERROR_CREATE, HSOCKET_ERROR_GET_HOSTNAME, hssl_client_ssl(), log_error2, log_verbose4, and hsocket_t::sock. |
|
Reads data from the socket.
Definition at line 453 of file nanohttp-socket.c. References hsocket_t::bytes_received, H_OK, herror_message(), herror_new(), HSOCKET_ERROR_RECEIVE, hsocket_select_recv(), hssl_read(), log_warn2, and hsocket_t::sock. Referenced by hrequest_new_from_socket(), and hresponse_new_from_socket(). |
|
Definition at line 431 of file nanohttp-socket.c. References log_verbose2. Referenced by hsocket_recv(), and hssl_read(). |
|
Sends data throught the socket.
Definition at line 387 of file nanohttp-socket.c. References hsocket_t::bytes_received, H_OK, herror_message(), herror_new(), HSOCKET_ERROR_NOT_INITIALIZED, HSOCKET_ERROR_SEND, hssl_write(), log_warn2, and hsocket_t::sock. Referenced by hsocket_send_string(), http_output_stream_write(), httpc_send_header(), and httpd_send_header(). |
|
Sends a string throught the socket
Definition at line 425 of file nanohttp-socket.c. References hsocket_send(). Referenced by http_output_stream_flush(), http_output_stream_write(), and httpc_send_header(). |
|
Set the socket read/write timeout.
Definition at line 507 of file nanohttp-socket.c. Referenced by httpd_set_timeout(). |