#include <stdlib.h>
#include <util/basicDefs.h>
#include <sys/socket.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <util/msgUtil.h>
Include dependency graph for xmlBlasterSocket.h:
This graph shows which files directly or indirectly include this file:
Go to the source code of this file.
Data Structures | |
struct | SocketDataHolder |
Helper struct to hold all necessary informations. More... | |
Defines | |
#define | MAX_MSG_LEN 1000000000 |
#define | MSG_LEN_FIELD_LEN 10 |
#define | MAX_PACKET_SIZE 10*1024 |
#define | MSG_FLAG_FIELD_LEN 6 |
#define | XMLBLASTER_SOCKET_VERSION 49 |
Typedefs | |
typedef enum XMLBLASTER_MSG_TYPE_ENUM | XMLBLASTER_MSG_TYPE |
Settings for MSG_FLAG_POS_TYPE. | |
Enumerations | |
enum | XMLBLASTER_MSG_TYPE_ENUM { MSG_TYPE_INVOKE = 73, MSG_TYPE_RESPONSE = 82, MSG_TYPE_EXCEPTION = 69 } |
Settings for MSG_FLAG_POS_TYPE. More... | |
enum | MSG_FLAG_POS_ENUM { MSG_FLAG_POS_CHECKSUM = 10, MSG_FLAG_POS_COMPRESS, MSG_FLAG_POS_TYPE, MSG_FLAG_POS_RESERVED1, MSG_FLAG_POS_RESERVED2, MSG_FLAG_POS_VERSION, MSG_POS_REQESTID } |
Functions | |
void | closeSocket (int fd) |
ssize_t | writen (const int fd, const char *ptr, const size_t nbytes) |
ssize_t | readn (const int fd, char *ptr, const size_t nbytes, XmlBlasterNumReadFunc fpNumRead, void *userP) |
Read the given amount of bytes from socket. | |
int | xbl_isOneway (XMLBLASTER_MSG_TYPE msgType, const char *const methodName) |
char * | encodeSocketMessage (enum XMLBLASTER_MSG_TYPE_ENUM msgType, const char *const requestId, const char *const methodName, const char *const secretSessionId, const char *data, size_t dataLen, int debug, size_t *rawMsgLen) |
Creates a raw blob to push over a socket as described in the protocol.socket requirement. | |
BlobHolder | encodeMsgUnit (MsgUnit *msgUnit, int debug) |
Creates a raw blob to push over a socket as described in protocol.socket. | |
BlobHolder | encodeMsgUnitArr (MsgUnitArr *msgUnitArr, int debug) |
Creates a raw blob to push over a socket as described in protocol.socket. | |
int | parseSocketData (int xmlBlasterSocket, const XmlBlasterReadFromSocketFuncHolder *fpHolder, SocketDataHolder *socketDataHolder, XmlBlasterException *exception, int *stopP, int udp, int debug) |
void | convertToXmlBlasterException (const XmlBlasterBlob *blob, XmlBlasterException *exception, int debug) |
void | encodeXmlBlasterException (XmlBlasterBlob *blob, const XmlBlasterException *exception, int debug) |
MsgUnitArr * | parseMsgUnitArr (size_t dataLen, char *data) |
Parses the userData part of a raw socket message and fills an array of MsgUnit structs. | |
QosArr * | parseQosArr (size_t dataLen, char *data) |
Parses the QoS XML string array returned by erase() and unSubscribe(). |
#define MAX_MSG_LEN 1000000000 |
#define MAX_PACKET_SIZE 10*1024 |
#define MSG_FLAG_FIELD_LEN 6 |
Definition at line 78 of file xmlBlasterSocket.h.
#define MSG_LEN_FIELD_LEN 10 |
Definition at line 76 of file xmlBlasterSocket.h.
Referenced by encodeSocketMessage(), and parseSocketData().
#define XMLBLASTER_SOCKET_VERSION 49 |
Definition at line 90 of file xmlBlasterSocket.h.
Referenced by encodeSocketMessage(), parseSocketData(), and sendData().
typedef enum XMLBLASTER_MSG_TYPE_ENUM XMLBLASTER_MSG_TYPE |
Settings for MSG_FLAG_POS_TYPE.
enum MSG_FLAG_POS_ENUM |
MSG_FLAG_POS_CHECKSUM | |
MSG_FLAG_POS_COMPRESS | |
MSG_FLAG_POS_TYPE | |
MSG_FLAG_POS_RESERVED1 | |
MSG_FLAG_POS_RESERVED2 | |
MSG_FLAG_POS_VERSION | |
MSG_POS_REQESTID |
Definition at line 80 of file xmlBlasterSocket.h.
void closeSocket | ( | int | fd | ) |
Definition at line 12 of file xmlBlasterSocket.c.
Referenced by closeAcceptSocket(), shutdownCallbackServer(), and xmlBlasterConnectionShutdown().
void convertToXmlBlasterException | ( | const XmlBlasterBlob * | blob, | |
XmlBlasterException * | exception, | |||
int | debug | |||
) |
BlobHolder encodeMsgUnit | ( | MsgUnit * | msgUnit, | |
int | debug | |||
) |
Creates a raw blob to push over a socket as described in protocol.socket.
msgUnit | The message which we need to send | |
debug | Pass true for debugging output to stdout |
Definition at line 119 of file xmlBlasterSocket.c.
References MsgUnit::content, MsgUnit::contentLen, BlobHolder::data, BlobHolder::dataLen, MsgUnit::key, MsgUnit::qos, and SNPRINTF.
Referenced by encodeXmlBlasterException(), sendResponse(), sendXmlBlasterException(), and xmlBlasterPublish().
BlobHolder encodeMsgUnitArr | ( | MsgUnitArr * | msgUnitArr, | |
int | debug | |||
) |
Creates a raw blob to push over a socket as described in protocol.socket.
msgUnitArr | An array of messages | |
debug | Set to true if you wish debugging output to stdout |
Definition at line 176 of file xmlBlasterSocket.c.
References MsgUnit::contentLen, BlobHolder::dataLen, MsgUnitStructArr::len, MsgUnitStructArr::msgUnitArr, and snprintf0().
Referenced by xmlBlasterPublishArr(), and xmlBlasterPublishOneway().
Here is the call graph for this function:
char* encodeSocketMessage | ( | enum XMLBLASTER_MSG_TYPE_ENUM | msgType, | |
const char *const | requestId, | |||
const char *const | methodName, | |||
const char *const | secretSessionId, | |||
const char * | data, | |||
size_t | dataLen, | |||
int | debug, | |||
size_t * | rawMsgLen | |||
) |
Creates a raw blob to push over a socket as described in the protocol.socket requirement.
msgType | invoke, response or exception | |
requestId | The unique request ID for each invocation | |
methodName | The method name like "PUBLISH" | |
secretSessionId | The authentication string | |
data | is returned | |
dataLen | is returned | |
debug | Pass true for debugging output to stdout | |
rawMsgLen |
requestId | The unique request ID for each invocation |
void encodeXmlBlasterException | ( | XmlBlasterBlob * | blob, | |
const XmlBlasterException * | exception, | |||
int | debug | |||
) |
MsgUnitArr* parseMsgUnitArr | ( | size_t | dataLen, | |
char * | data | |||
) |
Parses the userData part of a raw socket message and fills an array of MsgUnit structs.
Definition at line 553 of file xmlBlasterSocket.c.
References MsgUnit::content, MsgUnit::contentLen, MsgUnitStructArr::isOneway, MsgUnit::key, MsgUnitStructArr::len, MsgUnitStructArr::msgUnitArr, MsgUnit::qos, strcpyAlloc(), strncpy0(), strToULong(), and trim().
Referenced by parseQosArr(), and xmlBlasterGet().
Here is the call graph for this function:
QosArr* parseQosArr | ( | size_t | dataLen, | |
char * | data | |||
) |
Parses the QoS XML string array returned by erase() and unSubscribe().
Definition at line 534 of file xmlBlasterSocket.c.
References freeMsgUnitArr(), MsgUnitStructArr::len, QosStructArr::len, MsgUnitStructArr::msgUnitArr, parseMsgUnitArr(), MsgUnit::qos, QosStructArr::qosArr, and strcpyAlloc().
Referenced by xmlBlasterErase(), and xmlBlasterUnSubscribe().
Here is the call graph for this function:
int parseSocketData | ( | int | xmlBlasterSocket, | |
const XmlBlasterReadFromSocketFuncHolder * | fpHolder, | |||
SocketDataHolder * | socketDataHolder, | |||
XmlBlasterException * | exception, | |||
int * | stopP, | |||
int | udp, | |||
int | debug | |||
) |
ssize_t readn | ( | int | fd, | |
char * | ptr, | |||
size_t | nbytes, | |||
XmlBlasterNumReadFunc | fpNumRead, | |||
void * | userP | |||
) |
Read the given amount of bytes from socket.
This method blocks until data arrives, we loop as the low level recv() can return when the socket buffer is empty but not all data expected arrived.
This code is not thread safe, you need to add a mutex to your calling code if two threads simultaneously want to read from the same socket 'fd'.
fd | The socket descriptor | |
ptr | A buffer which is big enough to hold nbytes | |
nbytes | The number of bytes to read | |
fpNumRead | Function pointer, if not null we make a callback about the progress | |
userP | Is bounced back to fpNumRead |
Definition at line 68 of file xmlBlasterSocket.c.
Referenced by readnPlain().
ssize_t writen | ( | const int | fd, | |
const char * | ptr, | |||
const size_t | nbytes | |||
) |
int xbl_isOneway | ( | XMLBLASTER_MSG_TYPE | msgType, | |
const char *const | methodName | |||
) |