18 #ifndef TCP_TRANSPORTER_HPP
19 #define TCP_TRANSPORTER_HPP
21 #include "Transporter.hpp"
26 Uint32 *startOfBuffer;
42 void incompleteMessage();
60 bool initTransporter();
77 NDB_SOCKET_TYPE getSocket()
const;
85 virtual Uint32 getReceiveData(Uint32 ** ptr);
90 virtual void updateReceiveDataPtr(Uint32 bytesRead);
92 inline bool hasReceiveData ()
const {
93 return receiveBuffer.sizeOfData > 0;
103 virtual bool connect_client_impl(NDB_SOCKET_TYPE sockfd);
104 bool connect_common(NDB_SOCKET_TYPE sockfd);
113 NDB_SOCKET_TYPE theSocket;
115 Uint32 maxReceiveSize;
120 int sockOptRcvBufSize;
121 int sockOptSndBufSize;
123 int sockOptTcpMaxSeg;
125 void setSocketOptions(NDB_SOCKET_TYPE socket);
127 static bool setSocketNonBlocking(NDB_SOCKET_TYPE aSocket);
128 virtual int pre_connect_options(NDB_SOCKET_TYPE aSocket);
130 bool send_is_possible(
int timeout_millisec)
const;
131 bool send_is_possible(NDB_SOCKET_TYPE fd,
int timeout_millisec)
const;
144 bool send_limit_reached(
int bufsize) {
return bufsize > TCP_SEND_LIMIT; }
149 TCP_Transporter::getSocket()
const {
155 TCP_Transporter::getReceiveData(Uint32 ** ptr){
156 (* ptr) = receiveBuffer.readPtr;
157 return receiveBuffer.sizeOfData;
162 TCP_Transporter::updateReceiveDataPtr(Uint32 bytesRead){
163 char * ptr = (
char *)receiveBuffer.readPtr;
165 receiveBuffer.readPtr = (Uint32*)ptr;
166 receiveBuffer.sizeOfData -= bytesRead;
167 receiveBuffer.incompleteMessage();
172 ReceiveBuffer::init(
int bytes){
173 #ifdef DEBUG_TRANSPORTER
174 ndbout <<
"Allocating " << bytes <<
" bytes as receivebuffer" << endl;
177 startOfBuffer =
new Uint32[((bytes + 0) >> 2) + 1];
178 sizeOfBuffer = bytes +
sizeof(Uint32);
185 ReceiveBuffer::destroy(){
186 delete[] startOfBuffer;
194 ReceiveBuffer::clear(){
195 readPtr = startOfBuffer;
196 insertPtr = (
char *)startOfBuffer;
202 ReceiveBuffer::incompleteMessage() {
203 if(startOfBuffer != readPtr){
205 memmove(startOfBuffer, readPtr, sizeOfData);
206 readPtr = startOfBuffer;
207 insertPtr = ((
char *)startOfBuffer) + sizeOfData;
212 #endif // Define of TCP_Transporter_H