Ejemplo n.º 1
0
int mySocket::getReceiveBufSize()
{
    int rcvBuf;
    int myOptionLen = sizeof(rcvBuf);

	try 
	{
		if ( getsockopt(socketId,SOL_SOCKET,SO_RCVBUF,(char *)&rcvBuf,&myOptionLen) == -1 )
		{
			#ifdef WINDOWS_XP
				int errorCode;
				string errorMsg = "get RCVBUF option: ";
				detectErrorGetSocketOption(&errorCode,errorMsg);
				myException* socketOptionException = new myException(errorCode,errorMsg);
				throw socketOptionException;
			#endif

			#ifdef UNIX
				myException* unixSocketOptionException = new myException(0,"unix: error getting host by name");
				throw unixSocketOptionException;
			#endif
        }
	}
    catch(myException* excp)
	{
		excp->response();
		delete excp;
		exit(1);
	}
    return rcvBuf;
}
Ejemplo n.º 2
0
bool mySocket::getLingerOnOff()
{
	struct linger lingerOption;
	int myOptionLen = sizeof(struct linger);

	try 
	{
		if ( getsockopt(socketId,SOL_SOCKET,SO_LINGER,(char *)&lingerOption,&myOptionLen) == -1 )
		{
			#ifdef WINDOWS_XP
				int errorCode;
				string errorMsg = "get LINER option: ";
				detectErrorGetSocketOption(&errorCode,errorMsg);
				myException* socketOptionException = new myException(errorCode,errorMsg);
				throw socketOptionException;
			#endif

			#ifdef UNIX
				myException* unixSocketOptionException = new myException(0,"unix: error getting host by name");
				throw unixSocketOptionException;
			#endif
        }
	}
    catch(myException* excp)
	{
		excp->response();
		delete excp;
		exit(1);
	}

	if ( lingerOption.l_onoff == 1 ) return true;
	else return false;
}
Ejemplo n.º 3
0
int mySocket::getKeepAlive()
{
    int myOption;        
    int myOptionLen = sizeof(myOption);

	try 
	{
		if ( getsockopt(socketId,SOL_SOCKET,SO_KEEPALIVE,(char *)&myOption,&myOptionLen) == -1 )
		{
			#ifdef WINDOWS_XP
				int errorCode;
				string errorMsg = "get KEEPALIVE option: ";
				detectErrorGetSocketOption(&errorCode,errorMsg);
				myException* socketOptionException = new myException(errorCode,errorMsg);
				throw socketOptionException;
			#endif

			#ifdef UNIX
				myException* unixSocketOptionException = new myException(0,"unix: error getting host by name");
				throw unixSocketOptionException;
			#endif
        }
	}
    catch(myException* excp)
	{
		excp->response();
		delete excp;
		exit(1);
	}
    return myOption;    
}
Ejemplo n.º 4
0
int MySocket::getSendBufSize()
{
    int sendBuf;
    int myOptionLen = sizeof(sendBuf);

	try 
	{
		if ( getsockopt(m_nSocketId,SOL_SOCKET,SO_SNDBUF,(char *)&sendBuf,&myOptionLen) == -1 )
		{
			#ifdef WINDOWS_XP
				int errorCode;
				string errorMsg = "get SNDBUF option: ";
				detectErrorGetSocketOption(&errorCode,errorMsg);
				MyException socketOptionException(errorCode,errorMsg);
				throw socketOptionException;
			#endif

			#ifdef UNIX
				MyException unixSocketOptionException(0,"unix: error getting host by name");
				throw unixSocketOptionException;
			#endif
        }
	}
    catch(MyException& excp)
	{
		excp.response();
		exit(1);
	}
    return sendBuf;
}    
Ejemplo n.º 5
0
int MySocket::getLingerSeconds()
{
	struct linger lingerOption;
	int myOptionLen = sizeof(struct linger);

	try 
	{
		if ( getsockopt(m_nSocketId,SOL_SOCKET,SO_LINGER,(char *)&lingerOption,&myOptionLen) == -1 )
		{
			#ifdef WINDOWS_XP
				int errorCode;
				string errorMsg = "get LINER option: ";
				detectErrorGetSocketOption(&errorCode,errorMsg);
				MyException socketOptionException(errorCode,errorMsg);
				throw socketOptionException;
			#endif

			#ifdef UNIX
				MyException unixSocketOptionException(0,"unix: error getting host by name");
				throw unixSocketOptionException;
			#endif
        }
	}
    catch(MyException& excp)
	{
		excp.response();
		exit(1);
	}

	return lingerOption.l_linger;
}
Ejemplo n.º 6
0
int MySocket::getReuseAddr()
{
    int myOption;        
    int myOptionLen = sizeof(myOption);

	try 
	{
		if ( getsockopt(m_nSocketId,SOL_SOCKET,SO_REUSEADDR,(char *)&myOption,&myOptionLen) == -1 )
		{
			#ifdef WINDOWS_XP
				int errorCode;
				string errorMsg = "get REUSEADDR option: ";
				detectErrorGetSocketOption(&errorCode,errorMsg);
				MyException socketOptionException(errorCode,errorMsg);
				throw socketOptionException;
			#endif

			#ifdef UNIX
				MyException unixSocketOptionException(0,"unix: error getting host by name");
				throw unixSocketOptionException;
			#endif
        }
	}
    catch(MyException& excp)
	{
		excp.response();
		exit(1);
	}

	return myOption;
}