improved comments of globally used functions

This commit is contained in:
Igor Socec 2014-03-18 18:48:37 +01:00
parent c312659292
commit 89b8716985
4 changed files with 153 additions and 22 deletions

View file

@ -1,7 +1,13 @@
#include "moxerver.h"
/* Sets up the server on specific port, binds to a socket and listens for client connections. */
/**
* Sets up the server on specific port, binds to a socket and listens for client connections.
*
* Returns:
* - 0 on success,
* - negative errno value set appropriately by error in setup process
*/
int server_setup(struct server_t *server, unsigned int port) {
int namelen, opt;
@ -47,7 +53,7 @@ int server_setup(struct server_t *server, unsigned int port) {
}
if (ntohs(server->address.sin_port) != port) {
fprintf(stderr, "[%s:%d] error: could not assign port %u\n", __func__, __LINE__, port);
return -1;
return -1; //TODO find appropriate errno for this
}
/* save server port number */
server->port = port;
@ -63,7 +69,12 @@ int server_setup(struct server_t *server, unsigned int port) {
return 0;
}
/* Closes the server. */
/**
* Closes the server socket.
*
* Returns:
* 0 always, but internally tries closing again if it fails.
*/
int server_close(struct server_t *server) {
/* force closing in case of error */
if (close(server->socket) == -1) {
@ -73,7 +84,13 @@ int server_close(struct server_t *server) {
return 0;
}
/* Accepts incoming client connection. */
/**
* Accepts incoming client connection.
*
* Returns:
* - 0 on success,
* - negative errno value set appropriately by error in setup process
*/
int server_accept(struct server_t *server, struct client_t *accepted_client) {
int namelen;
@ -102,7 +119,12 @@ int server_accept(struct server_t *server, struct client_t *accepted_client) {
return 0;
}
/* Rejects incoming client connection. */
/**
* Rejects incoming client connection.
*
* Returns:
* 0 always, errors with rejected client are ignored
*/
int server_reject(struct server_t *server) {
int namelen;