Exemplo n.º 1
0
void myTcpSocket::bindSocket()
{
	try
	{
		if (bind(socketId,(struct sockaddr *)&clientAddr,sizeof(struct sockaddr_in))==-1)
		{
			#ifdef WINDOWS_XP
				int errorCode = 0;
				string errorMsg = "error calling bind(): \n";
				detectErrorBind(&errorCode,errorMsg);
				myException* socketBindException = new myException(errorCode,errorMsg);
				throw socketBindException;
			#endif
			#ifdef UNIX
				myException* unixSocketBindException = new myException(0,"unix: error calling bind()");
				throw unixSocketBindException;
			#endif
        }
	}
    catch(myException* excp)
	{
		excp->response();
		delete excp;
		exit(1);
	}
}
Exemplo n.º 2
0
void MyTcpSocket::bindSocket()
{
	try
	{
		if (bind(m_nSocketId,(struct sockaddr *)&m_stutNetAddr,sizeof(struct sockaddr_in))==-1)
		{
			#ifdef WINDOWS_XP
				int errorCode = 0;
				string errorMsg = "error calling bind(): \n";
				detectErrorBind(&errorCode,errorMsg);
				MyException socketBindException(errorCode,errorMsg);
				throw socketBindException;
			#endif
			#ifdef UNIX
				MyException unixSocketBindException(0,"unix: error calling bind()");
				throw unixSocketBindException;
			#endif
        }
	}
    catch(MyException& excp)
	{
		excp.response();
		exit(1);
	}
}