Commit 4334ad60 authored by Steven Murray's avatar Steven Murray
Browse files

Re-factorised the processing of the VDQM RCP job submission request into its

own function:

  castor::tape:aggregator::VdqmRequestHandlerThread::processJobSubmissionRequest

Started to refactorise out the giving of file lists to RTCPD.
parent ffb56c19
......@@ -19,7 +19,7 @@
*
*
*
* @author Steven Murray Steven.Murray@cern.ch
* @author Nicola.Bessone@cern.ch Steven.Murray@cern.ch
*****************************************************************************/
......
......@@ -19,7 +19,7 @@
*
*
*
* @author Steven Murray Steven.Murray@cern.ch
* @author Nicola.Bessone@cern.ch Steven.Murray@cern.ch
*****************************************************************************/
#ifndef CASTOR_TAPE_AGGREGATOR_AGGREGATORDAEMON_HPP
......
/* This file was generated by ./AggregatorDlfMessagesCodeGenerator on Fri Jan 23 11:26:28 CET 2009
/* This file was generated by ./AggregatorDlfMessagesCodeGenerator on Thu Jan 29 12:04:57 CET 2009
*/
/******************************************************************************
......@@ -39,7 +39,7 @@ AGGREGATOR_FAILED_TO_PARSE_COMMAND_LINE=2, /* "Failed to parse the command line"
AGGREGATOR_FAILED_TO_INIT_DB_SERVICE=3, /* "Failed to initialise database service" */
AGGREGATOR_VDQM_REQUEST_HANDLER_SOCKET_IS_NULL=4, /* "The VdqmRequestHandlerThread has been passed a NULL socket pointer" */
AGGREGATOR_VDQM_CONNECTION_WITH_INFO=5, /* "Received a connection from VDQM" */
AGGREGATOR_VDQM_CONNECTION_WITHOUT_INFO=6, /* "Received a connection from VDQM without peer host and port information" */
AGGREGATOR_VDQM_CONNECTION_WITHOUT_INFO=6, /* "Received a connection from VDQM without peer information" */
AGGREGATOR_HANDLE_VDQM_REQUEST_EXCEPT=7, /* "Exception raised when handling a request from the VDQM" */
AGGREGATOR_FAILED_TO_READ_MESSAGE_HEADER=8, /* "Failed to read message header" */
AGGREGATOR_UNKNOWN_MAGIC=9, /* "Unknown magic number" */
......@@ -54,7 +54,7 @@ AGGREGATOR_FAILED_TO_PROCESS_RCP_JOB_SUBMISSION=17, /* "Failed to process RCP jo
AGGREGATOR_RECEIVED_RTCPD_ERROR_MESSAGE=18, /* "Received error message from RTCPD" */
AGGREGATOR_RTCPD_HANDLER_SOCKET_IS_NULL=19, /* "The RtcpdHandlerThread has been passed a NULL socket pointer" */
AGGREGATOR_RTCPD_CONNECTION_WITH_INFO=20, /* "Received a connection from RTCPD" */
AGGREGATOR_RTCPD_CONNECTION_WITHOUT_INFO=21, /* "Received a connection from RTCPD without peer host and port information" */
AGGREGATOR_RTCPD_CONNECTION_WITHOUT_INFO=21, /* "Received a connection from RTCPD without peer information" */
AGGREGATOR_GOT_VOLREQID=22, /* "Got volume request ID from RTCPD" */
AGGREGATOR_FAILED_TO_GET_VOLREQID=23, /* "Failed to get volume request ID from RTCPD" */
AGGREGATOR_FAILED_TO_MARSHALL_RCP_JOB_REPLY_MESSAGE=24, /* "Failed to marshall RCP job reply message" */
......
/* This file was generated by ./AggregatorDlfMessagesCodeGenerator on Fri Jan 23 11:26:28 CET 2009
/* This file was generated by ./AggregatorDlfMessagesCodeGenerator on Thu Jan 29 12:04:57 CET 2009
*/
/******************************************************************************
......@@ -35,7 +35,7 @@ castor::dlf::Message castor::tape::aggregator::AggregatorDaemon::s_dlfMessages[]
{AGGREGATOR_FAILED_TO_INIT_DB_SERVICE, "Failed to initialise database service"},
{AGGREGATOR_VDQM_REQUEST_HANDLER_SOCKET_IS_NULL, "The VdqmRequestHandlerThread has been passed a NULL socket pointer"},
{AGGREGATOR_VDQM_CONNECTION_WITH_INFO, "Received a connection from VDQM"},
{AGGREGATOR_VDQM_CONNECTION_WITHOUT_INFO, "Received a connection from VDQM without peer host and port information"},
{AGGREGATOR_VDQM_CONNECTION_WITHOUT_INFO, "Received a connection from VDQM without peer information"},
{AGGREGATOR_HANDLE_VDQM_REQUEST_EXCEPT, "Exception raised when handling a request from the VDQM"},
{AGGREGATOR_FAILED_TO_READ_MESSAGE_HEADER, "Failed to read message header"},
{AGGREGATOR_UNKNOWN_MAGIC, "Unknown magic number"},
......@@ -50,7 +50,7 @@ castor::dlf::Message castor::tape::aggregator::AggregatorDaemon::s_dlfMessages[]
{AGGREGATOR_RECEIVED_RTCPD_ERROR_MESSAGE, "Received error message from RTCPD"},
{AGGREGATOR_RTCPD_HANDLER_SOCKET_IS_NULL, "The RtcpdHandlerThread has been passed a NULL socket pointer"},
{AGGREGATOR_RTCPD_CONNECTION_WITH_INFO, "Received a connection from RTCPD"},
{AGGREGATOR_RTCPD_CONNECTION_WITHOUT_INFO, "Received a connection from RTCPD without peer host and port information"},
{AGGREGATOR_RTCPD_CONNECTION_WITHOUT_INFO, "Received a connection from RTCPD without peer information"},
{AGGREGATOR_GOT_VOLREQID, "Got volume request ID from RTCPD"},
{AGGREGATOR_FAILED_TO_GET_VOLREQID, "Failed to get volume request ID from RTCPD"},
{AGGREGATOR_FAILED_TO_MARSHALL_RCP_JOB_REPLY_MESSAGE, "Failed to marshall RCP job reply message"},
......
......@@ -4,7 +4,7 @@
3,AGGREGATOR_FAILED_TO_INIT_DB_SERVICE,"Failed to initialise database service"
4,AGGREGATOR_VDQM_REQUEST_HANDLER_SOCKET_IS_NULL,"The VdqmRequestHandlerThread has been passed a NULL socket pointer"
5,AGGREGATOR_VDQM_CONNECTION_WITH_INFO,"Received a connection from VDQM"
6,AGGREGATOR_VDQM_CONNECTION_WITHOUT_INFO,"Received a connection from VDQM without peer host and port information"
6,AGGREGATOR_VDQM_CONNECTION_WITHOUT_INFO,"Received a connection from VDQM without peer information"
7,AGGREGATOR_HANDLE_VDQM_REQUEST_EXCEPT,"Exception raised when handling a request from the VDQM"
8,AGGREGATOR_FAILED_TO_READ_MESSAGE_HEADER,"Failed to read message header"
9,AGGREGATOR_UNKNOWN_MAGIC,"Unknown magic number"
......@@ -19,7 +19,7 @@
18,AGGREGATOR_RECEIVED_RTCPD_ERROR_MESSAGE,"Received error message from RTCPD"
19,AGGREGATOR_RTCPD_HANDLER_SOCKET_IS_NULL,"The RtcpdHandlerThread has been passed a NULL socket pointer"
20,AGGREGATOR_RTCPD_CONNECTION_WITH_INFO,"Received a connection from RTCPD"
21,AGGREGATOR_RTCPD_CONNECTION_WITHOUT_INFO,"Received a connection from RTCPD without peer host and port information"
21,AGGREGATOR_RTCPD_CONNECTION_WITHOUT_INFO,"Received a connection from RTCPD without peer information"
22,AGGREGATOR_GOT_VOLREQID,"Got volume request ID from RTCPD"
23,AGGREGATOR_FAILED_TO_GET_VOLREQID,"Failed to get volume request ID from RTCPD"
24,AGGREGATOR_FAILED_TO_MARSHALL_RCP_JOB_REPLY_MESSAGE,"Failed to marshall RCP job reply message"
......
......@@ -19,7 +19,7 @@
*
*
*
* @author Steven Murray Steven.Murray@cern.ch
* @author Nicola.Bessone@cern.ch Steven.Murray@cern.ch
*****************************************************************************/
......
......@@ -20,7 +20,7 @@
*
*
*
* @author Steven Murray Steven.Murray@cern.ch
* @author Nicola.Bessone@cern.ch Steven.Murray@cern.ch
*****************************************************************************/
#ifndef CASTOR_TAPE_AGGREGATOR_CONSTANTS_HPP
......@@ -30,15 +30,17 @@
#include <stdlib.h>
namespace castor {
namespace tape {
namespace castor {
namespace tape {
namespace aggregator {
const size_t HDRBUFSIZ = 3 * sizeof(uint32_t);
const size_t MSGBUFSIZ = 1024;
const int NETRWTIMEOUT = 300;
const size_t STRERRORBUFLEN = 256;
const int LISTENBACKLOG = 2;
const size_t HDRBUFSIZ = 3 * sizeof(uint32_t);
const size_t HOSTNAMEBUFLEN = 256;
const int LISTENBACKLOG = 2;
const size_t MSGBUFSIZ = 1024;
const int NETRWTIMEOUT = 300;
const size_t SERVICENAMEBUFLEN = 256;
const size_t STRERRORBUFLEN = 256;
} // namespace aggregator
} // namespace tape
......
......@@ -36,8 +36,8 @@ AGGREGATORBIN_SRCS = \
AggregatorDaemon.cpp \
AggregatorMain.cpp \
Marshaller.cpp \
Net.cpp \
RcpJobSubmitter.cpp \
SocketHelper.cpp \
Transceiver.cpp \
Utils.cpp \
VdqmRequestHandlerThread.cpp
......
......@@ -20,7 +20,7 @@
*
*
*
* @author Steven Murray Steven.Murray@cern.ch
* @author Nicola.Bessone@cern.ch Steven.Murray@cern.ch
*****************************************************************************/
#include "castor/exception/Internal.hpp"
......@@ -37,7 +37,7 @@
// marshallUint8
//------------------------------------------------------------------------------
void castor::tape::aggregator::Marshaller::marshallUint8(uint8_t src,
char * &dst) throw (castor::exception::Exception) {
char * &dst) throw(castor::exception::Exception) {
marshallInteger(src, dst);
}
......@@ -57,7 +57,7 @@ void castor::tape::aggregator::Marshaller::unmarshallUint8(const char * &src,
// marshallUint16
//------------------------------------------------------------------------------
void castor::tape::aggregator::Marshaller::marshallUint16(uint16_t src,
char * &dst) throw (castor::exception::Exception) {
char * &dst) throw(castor::exception::Exception) {
marshallInteger(src, dst);
}
......@@ -77,7 +77,7 @@ void castor::tape::aggregator::Marshaller::unmarshallUint16(const char * &src,
// marshallUint32
//------------------------------------------------------------------------------
void castor::tape::aggregator::Marshaller::marshallUint32(uint32_t src,
char * &dst) throw (castor::exception::Exception) {
char * &dst) throw(castor::exception::Exception) {
marshallInteger(src, dst);
}
......@@ -97,7 +97,7 @@ void castor::tape::aggregator::Marshaller::unmarshallUint32(const char * &src,
// marshallInt32
//------------------------------------------------------------------------------
void castor::tape::aggregator::Marshaller::marshallInt32(int32_t src,
char * &dst) throw (castor::exception::Exception) {
char * &dst) throw(castor::exception::Exception) {
marshallInteger(src, dst);
}
......@@ -117,7 +117,7 @@ void castor::tape::aggregator::Marshaller::unmarshallInt32(const char * &src,
// marshallUint64
//------------------------------------------------------------------------------
void castor::tape::aggregator::Marshaller::marshallUint64(uint64_t src,
char * &dst) throw (castor::exception::Exception) {
char * &dst) throw(castor::exception::Exception) {
marshallInteger(src, dst);
}
......@@ -178,7 +178,7 @@ void castor::tape::aggregator::Marshaller::marshallString(
//------------------------------------------------------------------------------
void castor::tape::aggregator::Marshaller::unmarshallString(const char * &src,
size_t &srcLen, char *dst, const size_t dstLen)
throw (castor::exception::Exception) {
throw(castor::exception::Exception) {
if(src == NULL) {
castor::exception::Exception ex(EINVAL);
......@@ -318,7 +318,7 @@ void castor::tape::aggregator::Marshaller::unmarshallMessageHeader(
//-----------------------------------------------------------------------------
size_t castor::tape::aggregator::Marshaller::marshallRcpJobRequestMessage(
char *const dst, const size_t dstLen, const RcpJobRequestMessage &src)
throw (castor::exception::Exception) {
throw(castor::exception::Exception) {
if(dst == NULL) {
castor::exception::Exception ex(EINVAL);
......@@ -512,7 +512,7 @@ void castor::tape::aggregator::Marshaller::unmarshallRcpJobReplyMessageBody(
//-----------------------------------------------------------------------------
size_t castor::tape::aggregator::Marshaller::marshallRtcpTapeRequestMessage(
char *dst, const size_t dstLen, const RtcpTapeRequestMessage &src)
throw (castor::exception::Exception) {
throw(castor::exception::Exception) {
// Calculate the length of the message body
const uint32_t len =
......@@ -728,7 +728,7 @@ void castor::tape::aggregator::Marshaller::unmarshallRtcpAcknowledgeMessageBody(
//-----------------------------------------------------------------------------
size_t castor::tape::aggregator::Marshaller::marshallRtcpFileRequestMessage(
char *dst, const size_t dstLen, const RtcpFileRequestMessage &src)
throw (castor::exception::Exception) {
throw(castor::exception::Exception) {
// Calculate the length of the message body
const uint32_t len =
......@@ -940,7 +940,7 @@ void castor::tape::aggregator::Marshaller::unmarshallRtcpFileRequestMessageBody(
//-----------------------------------------------------------------------------
size_t castor::tape::aggregator::Marshaller::marshallRtcpNoMoreRequestsMessage(
char *dst, const size_t dstLen)
throw (castor::exception::Exception) {
throw(castor::exception::Exception) {
// Calculate the length of the message body
const uint32_t len = 0;
......
......@@ -20,7 +20,7 @@
*
*
*
* @author Steven Murray Steven.Murray@cern.ch
* @author Nicola.Bessone@cern.ch Steven.Murray@cern.ch
*****************************************************************************/
#ifndef CASTOR_TAPE_AGGREGATOR_MARSHALLER_HPP
......
......@@ -19,7 +19,7 @@
*
*
*
* @author Steven Murray Steven.Murray@cern.ch
* @author Nicola.Bessone@cern.ch Steven.Murray@cern.ch
*****************************************************************************/
#ifndef CASTOR_TAPE_AGGREGATOR_MESSAGEHEADER
......
/******************************************************************************
* SocketHelper.cpp
* Net.cpp
*
* This file is part of the Castor project.
* See http://castor.web.cern.ch/castor
......@@ -18,196 +18,281 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*
* @author Steven Murray Steven.Murray@cern.ch
*
*
* @author Nicola.Bessone@cern.ch Steven.Murray@cern.ch
*****************************************************************************/
#include "castor/exception/Internal.hpp"
#include "castor/io/AbstractTCPSocket.hpp"
#include "castor/tape/aggregator/Constants.hpp"
#include "castor/tape/aggregator/Marshaller.hpp"
#include "castor/tape/aggregator/SocketHelper.hpp"
#include "h/net.h"
#include "castor/tape/aggregator/Net.hpp"
#include "castor/tape/aggregator/Utils.hpp"
#include "h/serrno.h"
#include "h/socket_timeout.h"
#include <errno.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <sys/socket.h>
//------------------------------------------------------------------------------
// printIp
//------------------------------------------------------------------------------
void castor::tape::aggregator::SocketHelper::printIp(std::ostream &os,
const unsigned long ip) throw() {
os << ((ip >> 24) & 0x000000FF) << "."
<< ((ip >> 16) & 0x000000FF) << "."
<< ((ip >> 8) & 0x000000FF) << "."
<< ( ip & 0x000000FF);
//-----------------------------------------------------------------------------
// createListenerSocket
//-----------------------------------------------------------------------------
int castor::tape::aggregator::Net::createListenerSocket(
const unsigned short port) throw(castor::exception::Exception) {
int socketFd = 0;
struct sockaddr_in address;
if ((socketFd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) {
castor::exception::Exception ex(errno);
ex.getMessage() << __PRETTY_FUNCTION__
<< ": Failed to create a listener socket";
throw ex;
}
Utils::setBytes(address, 0);
address.sin_family = AF_INET;
address.sin_addr.s_addr = htonl(INADDR_ANY);
address.sin_port = htons(port);
if(bind(socketFd, (struct sockaddr *) &address, sizeof(address)) < 0) {
castor::exception::Exception ex(errno);
ex.getMessage() << __PRETTY_FUNCTION__
<< ": Failed to bind listener socket";
throw ex;
}
if(listen(socketFd, LISTENBACKLOG) < 0) {
castor::exception::Exception ex(errno);
ex.getMessage() << __PRETTY_FUNCTION__
<< ": Failed to mark listener socket as being a listener socket";
throw ex;
}
return socketFd;
}
//-----------------------------------------------------------------------------
// getSocketIpAndPort
//-----------------------------------------------------------------------------
void castor::tape::aggregator::Net::getSocketIpAndPort(const int socketFd,
unsigned long& ip, unsigned short& port)
throw(castor::exception::Exception) {
struct sockaddr_in address;
socklen_t addressLen = sizeof(address);
if(getsockname(socketFd, (struct sockaddr*)&address, &addressLen) < 0) {
const int getsocknameErrno = errno;
char strerrorBuf[STRERRORBUFLEN];
char *const errorStr = strerror_r(getsocknameErrno, strerrorBuf,
sizeof(strerrorBuf));
castor::exception::Exception ex(getsocknameErrno);
ex.getMessage() << __PRETTY_FUNCTION__
<< ": Failed to get socket name"
": " << errorStr;
throw ex;
}
ip = ntohl(address.sin_addr.s_addr);
port = ntohs(address.sin_port);
}
//-----------------------------------------------------------------------------
// getPeerIpAndPort
//-----------------------------------------------------------------------------
void castor::tape::aggregator::Net::getPeerIpAndPort(const int socketFd,
unsigned long& ip, unsigned short& port)
throw(castor::exception::Exception) {
struct sockaddr_in address;
socklen_t addressLen = sizeof(address);
if(getpeername(socketFd, (struct sockaddr*)&address, &addressLen) < 0) {
const int getpeernameErrno = errno;
char strerrorBuf[STRERRORBUFLEN];
char *const errorStr = strerror_r(getpeernameErrno, strerrorBuf,
sizeof(strerrorBuf));
castor::exception::Exception ex(getpeernameErrno);
ex.getMessage() << __PRETTY_FUNCTION__
<< ": Failed to get peer name"
": " << errorStr;
throw ex;
}
ip = ntohl(address.sin_addr.s_addr);
port = ntohs(address.sin_port);
}
//------------------------------------------------------------------------------
// printSocketDescription
// getSocketHostName
//------------------------------------------------------------------------------
void castor::tape::aggregator::SocketHelper::printSocketDescription(
std::ostream &os, castor::io::AbstractTCPSocket &socket) throw() {
unsigned short localPort = 0;
unsigned long localIp = 0;
unsigned short peerPort = 0;
unsigned long peerIp = 0;
void castor::tape::aggregator::Net::getSocketHostName(const int socketFd,
char *buf, size_t len) throw(castor::exception::Exception) {
socket.getPortIp(localPort, localIp);
socket.getPeerIp(peerPort , peerIp );
struct sockaddr_in address;
socklen_t addressLen = sizeof(address);
os << "local=";
printIp(os, localIp);
os << ":" << localPort;
os << " peer=";
printIp(os, peerIp);
os << ":" << peerPort;
if(getsockname(socketFd, (struct sockaddr*)&address, &addressLen) < 0) {
const int getsocknameErrno = errno;
char strerrorBuf[STRERRORBUFLEN];
char *const errorStr = strerror_r(getsocknameErrno, strerrorBuf,
sizeof(strerrorBuf));
castor::exception::Exception ex(getsocknameErrno);
ex.getMessage() << __PRETTY_FUNCTION__
<< ": Failed to get socket name"
": " << errorStr;
throw ex;
}
char hostName[HOSTNAMEBUFLEN];
char serviceName[SERVICENAMEBUFLEN];
const int error = getnameinfo((const struct sockaddr*)&address, addressLen,
hostName, sizeof(hostName), serviceName, sizeof(serviceName), 0);
if(error != 0) {
castor::exception::Exception ex(SENOSHOST);
ex.getMessage() << __PRETTY_FUNCTION__
<< ": Failed to get host information by address"
": " << gai_strerror(error);
throw ex;
}
Utils::copyString(buf, hostName, len);
}
//------------------------------------------------------------------------------
// readUint32
// getPeerHostName
//------------------------------------------------------------------------------
uint32_t castor::tape::aggregator::SocketHelper::readUint32(
castor::io::AbstractTCPSocket &socket, const int netReadWriteTimeout)
throw (castor::exception::Exception) {
void castor::tape::aggregator::Net::getPeerHostName(const int socketFd,
char *buf, size_t len) throw(castor::exception::Exception) {
uint32_t value = 0;
char buf[sizeof(value)];
struct sockaddr_in address;
socklen_t addressLen = sizeof(address);
const int netreadRc = netread_timeout(socket.socket(), buf, sizeof(value),
netReadWriteTimeout);
const int netreadErrno = errno;
if(getpeername(socketFd, (struct sockaddr*)&address, &addressLen) < 0) {
const int getpeernameErrno = errno;
switch(netreadRc) {
case -1:
{
char strerrbuf[STRERRORBUFLEN];
if(strerror_r(netreadErrno, strerrbuf, sizeof(strerrbuf))) {
strncpy(strerrbuf, "Uknown", sizeof(strerrbuf));
strerrbuf[sizeof(strerrbuf)-1] = '\0';
}
char strerrorBuf[STRERRORBUFLEN];
char *const errorStr = strerror_r(getpeernameErrno, strerrorBuf,
sizeof(strerrorBuf));
castor::exception::Exception ex(serrno);
castor::exception::Exception ex(getpeernameErrno);
ex.getMessage() << __PRETTY_FUNCTION__
<< ": Failed to get peer name"
": " << errorStr;
ex.getMessage() << __PRETTY_FUNCTION__;
std::ostream &os = ex.getMessage();
os << ": Failed to read unsigned 32-bit integer from socket: ";
printSocketDescription(os, socket);
os << ": " << netreadErrno << " - " << strerrbuf;
throw ex;
}
case 0:
{
castor::exception::Internal ex;
throw ex;
}
ex.getMessage() << __PRETTY_FUNCTION__;
std::ostream &os = ex.getMessage();
os << ": Failed to read unsigned 32-bit integer from socket: ";
printSocketDescription(os, socket);
os << ": Connection was closed by the remote end";
throw ex;
}
default:
if (netreadRc != sizeof(value)) {
castor::exception::Internal ex;
char hostName[HOSTNAMEBUFLEN];
char serviceName[SERVICENAMEBUFLEN];
const int error = getnameinfo((const struct sockaddr*)&address, addressLen,
hostName, sizeof(hostName), serviceName, sizeof(serviceName), 0);
ex.getMessage() << __PRETTY_FUNCTION__;
std::ostream &os = ex.getMessage();
os << ": Failed to read unsigned 32-bit from socket: ";
printSocketDescription(os, socket);
os << ": Read the wrong number of bytes"
<< ": Expected: " << sizeof(value)
<< ": Read: " << netreadRc;
throw ex;
}
}
if(error != 0) {
castor::exception::Exception ex(SENOSHOST);
const char *p = buf;
size_t bufLen = sizeof(buf);
ex.getMessage() << __PRETTY_FUNCTION__
<< ": Failed to get host information by address"
": " << gai_strerror(error);
Marshaller::unmarshallUint32(p, bufLen, value);
throw ex;
}
return value;
Utils::copyString(buf, hostName, len);
}
//------------------------------------------------------------------------------
// writeUint32
// printIp
//------------------------------------------------------------------------------
void castor::tape::aggregator::SocketHelper::writeUint32(
castor::io::AbstractTCPSocket &socket, const int netReadWriteTimeout,
uint32_t value) throw(castor::exception::Exception) {
void castor::tape::aggregator::Net::printIp(std::ostream &os,
const unsigned long ip) throw() {
os << ((ip >> 24) & 0x000000FF) << "."
<< ((ip >> 16) & 0x000000FF) << "."
<< ((ip >> 8) & 0x000000FF) << "."
<< ( ip & 0x000000FF);
}
;
const int netwriteRc = netwrite_timeout(socket.socket(), &value,
sizeof(value), netReadWriteTimeout);
switch(netwriteRc) {
case -1:
{
castor::exception::Exception ex(SECOMERR);
ex.getMessage() << __PRETTY_FUNCTION__;
std::ostream &os = ex.getMessage();
os << ": Failed to write unsigned 32-bit integer to socket: ";
printSocketDescription(os, socket);
os << ": " << neterror();
throw ex;
}
case 0:
{
castor::exception::Exception ex(SECONNDROP);
ex.getMessage() << __PRETTY_FUNCTION__;
std::ostream &os = ex.getMessage();
os << ": Failed to write unsigned 32-bit integer to socket: ";
printSocketDescription(os, socket);
os << ": Connection dropped";
throw ex;
}
default:
if(netwriteRc != sizeof(value)) {
castor::exception::Exception ex(SECOMERR);
//------------------------------------------------------------------------------
// printSocketDescription
//------------------------------------------------------------------------------
void castor::tape::aggregator::Net::printSocketDescription(std::ostream &os,
const int socketFd) throw() {