#include "sockutils.h"#include <string.h>#include <errno.h>#include <stdio.h>#include <stdlib.h>Go to the source code of this file.
Defines | |
| #define | WINSOCK_MAJOR_VERSION 2 /*!< Ask for Winsock 2.2 */ |
| #define | WINSOCK_MINOR_VERSION 2 /*!< Ask for Winsock 2.2 */ |
| #define | SHUT_WR SD_SEND /*!< The control code for shutdown() is different in Win32 */ |
| #define | snprintf _snprintf /*!< The snprintf is called _snprintf() in Win32 */ |
| #define | SOCK_ERRBUF_SIZE 1024 |
| Size of the buffer that has to keep error messages. | |
| #define | SOCKET_NO_NAME_AVAILABLE "No name available" |
| #define | SOCKET_NO_PORT_AVAILABLE "No port available" |
| #define | SOCKET_NAME_NULL_DAD "Null address (possibly DAD Phase)" |
| #define | TEMP_BUF_SIZE 32768 |
Functions | |
| int | sock_ismcastaddr (const struct sockaddr *saddr) |
| It checks if the sockaddr variable contains a multicast address. | |
| void | sock_geterror (const char *caller, char *errbuf, int errbuflen) |
| It retrieves the error message after an error occurred in the socket interface. | |
| int | sock_init (char *errbuf, int errbuflen) |
| It initializes sockets. | |
| void | sock_cleanup () |
| It deallocates sockets. | |
| SOCKET | sock_open (struct addrinfo *addrinfo, int server, int nconn, char *errbuf, int errbuflen) |
| It initializes a network connection both from the client and the server side. | |
| int | sock_close (SOCKET sock, char *errbuf, int errbuflen) |
| Closes the present (TCP and UDP) socket connection. | |
| int | sock_initaddress (const char *address, const char *port, struct addrinfo *hints, struct addrinfo **addrinfo, char *errbuf, int errbuflen) |
| Checks that the address, port and flags given are valids and it returns an 'addrinfo' stucture. | |
| int | sock_send (SOCKET socket, const char *buffer, int size, char *errbuf, int errbuflen) |
| It sends the amount of data contained into 'buffer' on the given socket. | |
| int | sock_bufferize (const char *buffer, int size, char *tempbuf, int *offset, int totsize, int checkonly, char *errbuf, int errbuflen) |
| It copies the amount of data contained into 'buffer' into 'tempbuf'. and it checks for buffer overflows. | |
| int | sock_recv (SOCKET sock, char *buffer, int size, int receiveall, char *errbuf, int errbuflen) |
| It waits on a connected socket and it manages to receive data. | |
| int | sock_discard (SOCKET sock, int size, char *errbuf, int errbuflen) |
| It discards N bytes that are currently waiting to be read on the current socket. | |
| int | sock_check_hostlist (char *hostlist, const char *sep, struct sockaddr_storage *from, char *errbuf, int errbuflen) |
| Checks that one host (identified by the sockaddr_storage structure) belongs to an 'allowed list'. | |
| int | sock_cmpaddr (struct sockaddr_storage *first, struct sockaddr_storage *second) |
| Compares two addresses contained into two sockaddr_storage structures. | |
| int | sock_getmyinfo (SOCKET sock, char *address, int addrlen, char *port, int portlen, int flags, char *errbuf, int errbuflen) |
| It gets the address/port the system picked for this socket (on connected sockets). | |
| int | sock_getascii_addrport (const struct sockaddr_storage *sockaddr, char *address, int addrlen, char *port, int portlen, int flags, char *errbuf, int errbuflen) |
| It retrieves two strings containing the address and the port of a given 'sockaddr' variable. | |
| int | sock_present2network (const char *address, struct sockaddr_storage *sockaddr, int addr_family, char *errbuf, int errbuflen) |
| It translates an address from the 'presentation' form into the 'network' form. | |
Variables | |
| int | sockcount = 0 |
These calls do not want to provide a better socket interface; vice versa, they intend to provide a set of calls that is portable among several operating systems, hiding their differences.
Definition in file sockutils.c.
|
|
The control code for shutdown() is different in Win32 Definition at line 68 of file sockutils.c. Referenced by sock_close(). |
|
|
|
Size of the buffer that has to keep error messages.
Definition at line 74 of file sockutils.c. Referenced by sock_geterror(), and sock_open(). |
|
|
Definition at line 80 of file sockutils.c. Referenced by sock_getascii_addrport(). |
|
|
Definition at line 78 of file sockutils.c. Referenced by sock_getascii_addrport(). |
|
|
Definition at line 79 of file sockutils.c. Referenced by sock_getascii_addrport(). |
|
|
Referenced by sock_discard(). |
|
|
Ask for Winsock 2.2 Definition at line 61 of file sockutils.c. |
|
|
Ask for Winsock 2.2 Definition at line 62 of file sockutils.c. |
|
|
It checks if the sockaddr variable contains a multicast address.
Definition at line 255 of file sockutils.c. Referenced by sock_initaddress(). |
|
|
Variable that allows calling the WSAStartup() only one time Definition at line 63 of file sockutils.c. Referenced by sock_cleanup(), and sock_init(). |
documentation. Copyright (c) 2002-2003 Politecnico di Torino. All rights reserved.