51 #include <sys/types.h> 52 #include <sys/socket.h> 78 #if defined(debugSockUTest) && !defined(debugSock) 119 #define SOCK_RC_EFAIL (-1)
120 #define SOCK_RC_IODONE (-2)
121 #define SOCK_RC_EBUFFULL (-3)
122 #define SOCK_RC_EBADSOCK (-4)
123 #define SOCK_RC_ENOBUF (-5)
124 #define SOCK_RC_EBADSD (-6)
125 #define SOCK_RC_ESYSERR (-7)
130 #define SOCK_IO_READ 0 131 #define SOCK_IO_WRITE 1
132 #define SOCK_IO_NUMOF 2
138 #define SOCK_CHK_IO(io, ...) \ 139 CHKEXPR_INT(io, ((io) >= 0) && ((io) < SOCK_IO_NUMOF), __VA_ARGS__) 144 #define SOCK_SD_CLOSED (-1) 145 #define SOCK_PORT_NONE (-1)
211 struct sockaddr *pAddr,
212 const char *sHostName);
288 const char *sLocalHostName);
314 #ifdef debugSockUTest 316 extern void SocketUTest();
322 #endif // _RNR_SOCK_H void * SocketAttrGetClientData(Socket_T *pSocket)
Get Socket client user data.
size_t SocketBufGetSize(Socket_T *pSocket, int eIOBuf)
Get Socket buffer size.
INLINE_IN_H bool_t SocketAttrIsConnection(Socket_T *pSocket)
Test if socket is connection flavor.
char * SocketThisHostName()
Get the host string name of this network node (computer).
void SocketAttrSetLocalName(Socket_T *pSocket, const char *sHostName)
Set Socket local name.
int SocketAttrGetSd(Socket_T *pSocket)
Get Socket socket (file) descriptor.
connection/connectionless
Socket_T * SocketNew()
Allocate a new, unconnected socket.
void SocketDelete(Socket_T *pSocket)
Delate an allocated socket.
void SocketAttrSetSd(Socket_T *pSocket, int sd)
Set Socket socket (file) descriptor.
byte_t * SocketBufGetRawBuf(Socket_T *pSocket, int eIOBuf)
Get Socket raw buffer.
const char * SocketAttrGetLocalName(Socket_T *pSocket)
Get Socket local name.
SimpleBuf_T * SocketBufNewBuf(Socket_T *pSocket, int eIOBuf, size_t nBufSize)
Allocate a socket buffer and attach to Socket.
int SocketClose(Socket_T *pSocket)
Close a Socket.
ssize_t SocketRead(Socket_T *pSocket)
Reads the next available bytes from the Socket into in the Socket's read buffer.
Socket_T * SocketOpenTcpConnection(const char *sRemoteHostName, int ipPortRemote)
Create and open a new TCP/IP socket to the given remote host and port.
void SocketAttrSetRemoteName(Socket_T *pSocket, struct sockaddr *pAddr, const char *sHostName)
Set Socket remote name.
INLINE_IN_H bool_t SocketAttrIsConnectionless(Socket_T *pSocket)
Test if socket is connectionless flavor.
SimpleBuf_T * SocketBufSetBuf(Socket_T *pSocket, int eIOBuf, byte_t *pBuf, size_t nBufSize)
Attach a buffer to Socket.
int SocketAttrSetNonBlocking(Socket_T *pSocket)
Set Socket for non-blockiong I/O.
void SocketAttrSetFlavor(Socket_T *pSocket, SockFlavor eFlavor)
Set Socket flavor.
bool_t SocketStateIsOpen(Socket_T *pSocket)
Check if Socket is open.
SockFlavor SocketAttrGetFlavor(Socket_T *pSocket)
Get Socket flavor.
#define C_DECLS_BEGIN
C declaration block begin in C.
INLINE_IN_H bool_t SocketAttrIsListener(Socket_T *pSocket)
Test if socket is a listener flavor.
Socket_T * SocketOpenUdp(int ipPortUdp, const char *sLocalHostName)
Create and open a new UDP/IP connectionless socket. port.
RoadNarrows Robotics common configuration file.
#define INLINE_IN_H
inline C funtion in C header
Socket_T * SocketOpenTcpListener(int ipPortListener, const char *sLocalHostName)
Create and open a new TCP/IP passive listener socket on this host.
void SocketAttrSetPort(Socket_T *pSocket, int ipPort)
Set Socket port number.
Socket_T * SocketAccept(Socket_T *pSocketListener, bool_t bNonBlock)
Accept a client connection requst from the listener socket.
#define C_DECLS_END
C declaration block end in C.
bool_t SocketStateIsErrored(Socket_T *pSocket)
Check if Socket is in some kind of errored state.
size_t SocketBufGetLen(Socket_T *pSocket, int eIOBuf)
Get number of bytes in Socket buffer.
SimpleBuf_T * SocketBufGetBuf(Socket_T *pSocket, int eIOBuf)
Get Socket buffer.
Socket_T * SocketOpenUnixPair(int nType)
Create and open a new UNIX pair socket.
bool_t SocketAttrHasFlavor(Socket_T *pSocket, int nMask, int nFlavor)
Check if Socket has an assigned flavor.
void SocketBufClear(Socket_T *pSocket, int eIOBuf)
Clear a Socket buffer.
ssize_t SocketWriteAll(Socket_T *pSocket)
Writes all of the bytes from the socket's write buffer until no more bytes or error.
int SocketAttrGetPort(Socket_T *pSocket)
Get Socket port number.
void SocketAttrSetClientData(Socket_T *pSocket, void *pClientData)
Get Socket client user data.
const char * SocketAttrGetRemoteName(Socket_T *pSocket)
Get Socket remote name.
Simple [io] buffer declarations and operations.
Socket_T * SocketOpenUnix(int ipPortUdp, int nType)
Create and open a new UNIX connectionless socket.
ssize_t SocketWrite(Socket_T *pSocket)
Writes the bytes from the Socket's write buffer to the Socket connection.