Socket related functions. More...
#include "Socket.h"
#include "Log.h"
#include "SocketBuffer.h"
#include "Messages.h"
#include "StackTrace.h"
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <ctype.h>
#include "Heap.h"
Go to the source code of this file.
Macros | |
#define | ADDRLEN INET6_ADDRSTRLEN+1 |
#define | PORTLEN 10 |
Functions | |
int | isReady (int socket, fd_set *read_set, fd_set *write_set) |
int | Socket_abortWrite (int socket) |
void | Socket_addPendingWrite (int socket) |
int | Socket_addSocket (int newSd) |
void | Socket_clearPendingWrite (int socket) |
void | Socket_close (int socket) |
int | Socket_close_only (int socket) |
int | Socket_continueWrite (int socket) |
int | Socket_continueWrites (fd_set *pwset) |
int | Socket_error (char *aString, int sock) |
char * | Socket_getaddrname (struct sockaddr *sa, int sock) |
int | Socket_getch (int socket, char *c) |
char * | Socket_getdata (int socket, size_t bytes, size_t *actual_len, int *rc) |
char * | Socket_getpeer (int sock) |
int | Socket_getReadySocket (int more_work, struct timeval *tp, mutex_type mutex) |
int | Socket_new (const char *addr, size_t addr_len, int port, int *sock) |
int | Socket_noPendingWrites (int socket) |
void | Socket_outInitialize (void) |
void | Socket_outTerminate (void) |
int | Socket_putdatas (int socket, char *buf0, size_t buf0len, PacketBuffers bufs) |
int | Socket_setnonblocking (int sock) |
void | Socket_setWriteCompleteCallback (Socket_writeComplete *mywritecomplete) |
int | Socket_writev (int socket, iobuf *iovecs, int count, unsigned long *bytes) |
Variables | |
Sockets | mod_s |
static Socket_writeComplete * | writecomplete = NULL |
static fd_set | wset |
Socket related functions.
Some other related functions are in the SocketBuffer module
Definition in file Socket.c.
#define ADDRLEN INET6_ADDRSTRLEN+1 |
#define PORTLEN 10 |
int isReady | ( | int | socket, |
fd_set * | read_set, | ||
fd_set * | write_set | ||
) |
Don't accept work from a client unless it is accepting work back, i.e. its socket is writeable this seems like a reasonable form of flow control, and practically, seems to work.
socket | the socket to check |
read_set | the socket read set (see select doc) |
write_set | the socket write set (see select doc) |
int Socket_abortWrite | ( | int | socket | ) |
void Socket_addPendingWrite | ( | int | socket | ) |
Add a socket to the pending write list, so that it is checked for writing in select. This is used in connect processing when the TCP connect is incomplete, as we need to check the socket for both ready to read and write states.
socket | the socket to add |
int Socket_addSocket | ( | int | newSd | ) |
void Socket_clearPendingWrite | ( | int | socket | ) |
void Socket_close | ( | int | socket | ) |
int Socket_close_only | ( | int | socket | ) |
int Socket_continueWrite | ( | int | socket | ) |
int Socket_continueWrites | ( | fd_set * | pwset | ) |
int Socket_error | ( | char * | aString, |
int | sock | ||
) |
char * Socket_getaddrname | ( | struct sockaddr * | sa, |
int | sock | ||
) |
int Socket_getch | ( | int | socket, |
char * | c | ||
) |
char* Socket_getdata | ( | int | socket, |
size_t | bytes, | ||
size_t * | actual_len, | ||
int * | rc | ||
) |
Attempts to read a number of bytes from a socket, non-blocking. If a previous read did not finish, then retrieve that data.
socket | the socket to read from |
bytes | the number of bytes to read |
actual_len | the actual number of bytes read |
char* Socket_getpeer | ( | int | sock | ) |
int Socket_getReadySocket | ( | int | more_work, |
struct timeval * | tp, | ||
mutex_type | mutex | ||
) |
Returns the next socket ready for communications as indicated by select
more_work | flag to indicate more work is waiting, and thus a timeout value of 0 should be used for the select |
tp | the timeout to be used for the select, unless overridden |
int Socket_new | ( | const char * | addr, |
size_t | addr_len, | ||
int | port, | ||
int * | sock | ||
) |
int Socket_noPendingWrites | ( | int | socket | ) |
void Socket_outInitialize | ( | void | ) |
void Socket_outTerminate | ( | void | ) |
int Socket_putdatas | ( | int | socket, |
char * | buf0, | ||
size_t | buf0len, | ||
PacketBuffers | bufs | ||
) |
Attempts to write a series of buffers to a socket in one system call so that they are sent as one packet.
socket | the socket to write to |
buf0 | the first buffer |
buf0len | the length of data in the first buffer |
count | number of buffers |
buffers | an array of buffers to write |
buflens | an array of corresponding buffer lengths |
int Socket_setnonblocking | ( | int | sock | ) |
void Socket_setWriteCompleteCallback | ( | Socket_writeComplete * | mywritecomplete | ) |
int Socket_writev | ( | int | socket, |
iobuf * | iovecs, | ||
int | count, | ||
unsigned long * | bytes | ||
) |
Attempts to write a series of iovec buffers to a socket in one system call so that they are sent as one packet.
socket | the socket to write to |
iovecs | an array of buffers to write |
count | number of buffers in iovecs |
bytes | number of bytes actually written returned |
Sockets mod_s |
|
static |