Classes | Macros | Typedefs | Functions
Socket.h File Reference
#include <stdint.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/param.h>
#include <sys/time.h>
#include <sys/select.h>
#include <sys/uio.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
#include "mutex_type.h"
#include "LinkedList.h"
Include dependency graph for Socket.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  PacketBuffers
 
struct  Sockets
 

Macros

#define INET6_ADDRSTRLEN   46 /** only needed for gcc/cygwin on windows */
 
#define INVALID_SOCKET   SOCKET_ERROR
 
#define max(A, B)   ( (A) > (B) ? (A):(B))
 
#define SOCKET_ERROR   -1
 
#define SSL_FATAL   -3
 
#define TCPSOCKET_COMPLETE   0
 
#define TCPSOCKET_INTERRUPTED   -22
 
#define ULONG   size_t
 

Typedefs

typedef void Socket_writeComplete(int socket, int rc)
 

Functions

void Socket_addPendingWrite (int socket)
 
void Socket_clearPendingWrite (int socket)
 
void Socket_close (int socket)
 
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 *socket)
 
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)
 
void Socket_setWriteCompleteCallback (Socket_writeComplete *)
 

Macro Definition Documentation

#define INET6_ADDRSTRLEN   46 /** only needed for gcc/cygwin on windows */

Definition at line 83 of file Socket.h.

#define INVALID_SOCKET   SOCKET_ERROR

Definition at line 48 of file Socket.h.

#define max (   A,
 
)    ( (A) > (B) ? (A):(B))

Definition at line 88 of file Socket.h.

#define SOCKET_ERROR   -1

error in socket operation

Definition at line 76 of file Socket.h.

#define SSL_FATAL   -3

Definition at line 80 of file Socket.h.

#define TCPSOCKET_COMPLETE   0

socket operation completed successfully

Definition at line 73 of file Socket.h.

#define TCPSOCKET_INTERRUPTED   -22

must be the same as SOCKETBUFFER_INTERRUPTED

Definition at line 79 of file Socket.h.

#define ULONG   size_t

Definition at line 67 of file Socket.h.

Typedef Documentation

typedef void Socket_writeComplete(int socket, int rc)

Definition at line 142 of file Socket.h.

Function Documentation

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.

Parameters
socketthe socket to add

Definition at line 577 of file Socket.c.

void Socket_clearPendingWrite ( int  socket)

Clear a socket from the pending write list - if one was added with Socket_addPendingWrite

Parameters
socketthe socket to remove

Definition at line 587 of file Socket.c.

void Socket_close ( int  socket)

Close a socket and remove it from the select list.

Parameters
socketthe socket to close
Returns
completion code

Definition at line 627 of file Socket.c.

int Socket_getch ( int  socket,
char *  c 
)

Reads one byte from a socket

Parameters
socketthe socket to read from
cthe character read, returned
Returns
completion code

Definition at line 332 of file Socket.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.

Parameters
socketthe socket to read from
bytesthe number of bytes to read
actual_lenthe actual number of bytes read
Returns
completion code

Definition at line 370 of file Socket.c.

char* Socket_getpeer ( int  sock)

Get information about the other end connected to a socket

Parameters
sockthe socket to inquire on
Returns
the peer information

Definition at line 1058 of file Socket.c.

int Socket_getReadySocket ( int  more_work,
struct timeval *  tp,
mutex_type  mutex 
)

Returns the next socket ready for communications as indicated by select

Parameters
more_workflag to indicate more work is waiting, and thus a timeout value of 0 should be used for the select
tpthe timeout to be used for the select, unless overridden
Returns
the socket next ready, or 0 if none is ready

Definition at line 242 of file Socket.c.

int Socket_new ( const char *  addr,
size_t  addr_len,
int  port,
int *  sock 
)

Create a new socket and TCP connect to an address/port

Parameters
addrthe address string
portthe TCP port
sockreturns the new socket
timeoutthe timeout in milliseconds
Returns
completion code

Definition at line 671 of file Socket.c.

int Socket_noPendingWrites ( int  socket)

Indicate whether any data is pending outbound for a socket.

Returns
boolean - true == data pending.

Definition at line 417 of file Socket.c.

void Socket_outInitialize ( void  )

Initialize the socket module

Definition at line 122 of file Socket.c.

void Socket_outTerminate ( void  )

Terminate the socket module

Definition at line 151 of file Socket.c.

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.

Parameters
socketthe socket to write to
buf0the first buffer
buf0lenthe length of data in the first buffer
countnumber of buffers
buffersan array of buffers to write
buflensan array of corresponding buffer lengths
Returns
completion code, especially TCPSOCKET_INTERRUPTED

Definition at line 505 of file Socket.c.

void Socket_setWriteCompleteCallback ( Socket_writeComplete )

Definition at line 852 of file Socket.c.



plotjuggler
Author(s): Davide Faconti
autogenerated on Sun Dec 6 2020 04:02:49