Ejemplo n.º 1
0
void CSapConnection::HandleConnected(const boost::system::error_code& err,tcp::resolver::iterator endpoint_iterator)
{
    SS_XLOG(XLOG_DEBUG,"CSapConnection::%s,id[%d]\n",__FUNCTION__,m_nId);
    if (!err)
    {
        gettimeofday_a(&m_HeartBeatPoint,NULL);
        gettimeofday_a(&m_AlivePoint,NULL);
        ConnectFinish(0);
        m_isConnected=true;
        SetRemoteAddr();
		
        AsyncRead();
    }
    else if (endpoint_iterator != tcp::resolver::iterator())
    {
      boost::system::error_code ignore_ec;
      m_socket.close(ignore_ec);
      tcp::endpoint endpoint = *endpoint_iterator;
      m_socket.async_connect(endpoint,
          MakeSapAllocHandler(m_allocReader,boost::bind(&CSapConnection::HandleConnected, shared_from_this(),
            boost::asio::placeholders::error, ++endpoint_iterator)));
    }
    else
    {
        //SS_SLOG(XLOG_WARNING,"CSapConnection::"<<__FUNCTION__<<",id["<<m_nId<<"],addr[], error:" <<err.message()<<"\n");
		SS_XLOG(XLOG_WARNING,"CSapConnection::%s, id[%d],  error:%s\n",	__FUNCTION__,m_nId,(err.message()).c_str());
        ConnectFinish(-3);
    }
}
Ejemplo n.º 2
0
EXPORT_C TInt RFlowContext::Open(MFlowManager *aManager, const TSockAddr &aDst,	const TSockAddr &aSrc, TUint aProtocol, TUint aIcmpType, TUint aIcmpCode)
	/**
	* Just a convenience function, which combines Open, SetRemoteAddr, SetLocalAddr, SetIcmpInfo and Connect.
	*
	* @param aManager	Flow Manager
	* @param aDst		Flow's destination address (and port)
	* @param aSrc		Flow's source address (and port)
	* @param aProtocol	The upper layer protocol associated with the flow
	*					(and the value for the IP  NextHeader/Protocol field,
	*					unless some hook adds extension headers)
	* @param aIcmpType	ICMP type (only sensible when protocol is ICMP)
	* @param aIcmpCode	ICMP code (only sensible when protocol is ICMP)
	*
	* @return
	*		current value of CFlowContext::iStatus.
	*/
	{
	TInt ret = Open(aManager, aProtocol);
	if (ret != KErrNone)
		return ret;
	else if (iFlow)
		{
		SetRemoteAddr(aDst);
		SetLocalAddr(aSrc);
		SetIcmpType(aIcmpType, aIcmpCode);
		iFlow->Connect();
		return iFlow->iStatus;
		}
	else
		return KErrBadHandle;
	}