当前位置: 首页>>代码示例>>C++>>正文


C++ GetAddr函数代码示例

本文整理汇总了C++中GetAddr函数的典型用法代码示例。如果您正苦于以下问题:C++ GetAddr函数的具体用法?C++ GetAddr怎么用?C++ GetAddr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了GetAddr函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GetServAddr

SOCKET CClientSession::OpenStream( u_int nPasPort )
{
	SOCKADDR_IN addr;
	addr.sin_family = AF_INET;
	addr.sin_addr = GetServAddr().m_addrHost;
	addr.sin_port = htons( (u_short)nPasPort );

	SOCKET sock_stream = Socket( PF_INET, SOCK_STREAM, 0 );
	ASSERT( sock_stream!=INVALID_SOCKET );

	//import, must retry the socket initilization a few times.
	try{
		if( RedundantConnect( sock_stream, addr )!=0 )throw new CSockException();

		//open the data stream channel.
		CMessageBase msg;
		msg.Init( NCM_OPENSTREAM, GetAddr(), GetServAddr() );
		SendMessage( sock_stream, &msg );
		CMessageBase* pMsg = RecvMessage<CMessageBase>( sock_stream );
		if( pMsg==NULL )throw new CRemoteException(E_BROKENPIPE);

		CMessageTrash trash(pMsg);
		if( pMsg->IsFailed() )throw new CRemoteException( pMsg->GetResult() );
	}catch( ... ){
		CMessageBase msg;
		msg.Init( NCM_OPENSTREAM, GetAddr(), GetServAddr(), E_OPENSTREAM );
		m_pClntProxy->SendMessage( &msg );
		CMessageTrash trash(WaitForMessage( NCF_ACK|NCM_OPENSTREAM ) );
		closesocket( sock_stream );
		throw;
		return INVALID_SOCKET;
	}

	return sock_stream;
}
开发者ID:EISALab,项目名称:AMGAgroundwater,代码行数:35,代码来源:clntkel.cpp

示例2: DoPassive

HRESULT CClientSession::DoGetFile( const string& strFileName )
{
	//step 1. request passive mode to get the data channel address
	u_int nPasPort = 0;
	HRESULT hRet = DoPassive( nPasPort );
	if( FAILED(hRet) )return hRet;

	//step 2. send the put file command.
	CMessageHead* pMsg = (CMessageHead*)new char[sizeof(CMessageHead)+strFileName.length()+1];
	pMsg->Init( NCM_GETFILE, GetAddr(), GetServAddr() );
	pMsg->SetLength( sizeof(CMessageHead)+strFileName.length()+1 );
	strcpy( pMsg->GetData(), strFileName.c_str() );
	m_pClntProxy->SendMessage( pMsg );

	CMessage1Param<int>* pMsgAck = (CMessage1Param<int>*)GetMessage( NCF_ACK|NCM_GETFILE );
	CMessageTrash trash(pMsgAck->GetMessageHead());
	if( !pMsgAck->GetMessageHead()->IsSucceeded() )return pMsgAck->GetMessageHead()->GetResult();

	pMsgAck->ntoh();
	int nFileMode = pMsgAck->GetParam();

	//step 3. now the server agrees on the file transfer, connect the data channel and send file
	SOCKADDR_IN addr;
	addr.sin_family = AF_INET;
	addr.sin_addr = GetServAddr().m_addrHost;
	addr.sin_port = htons( (u_short)nPasPort );

	SOCKET sock_stream;
	//import, must retry the socket initilization a few times.
	int i;
	for( i=0; i<MAXRETRY; i++ ){
		sock_stream = Socket( PF_INET, SOCK_STREAM, 0 );
		ASSERT( sock_stream!=INVALID_SOCKET );

		if( ::connect( sock_stream, (SOCKADDR*)&addr, sizeof(SOCKADDR_IN) )==0 )break;
		closesocket( sock_stream );
	}
	if( i>=MAXRETRY )throw new CSockException();

	//open the data stream channel.
	CMessageHead msg;
	msg.Init( NCM_OPENSTREAM, GetAddr(), GetServAddr() );
	msg.Send( sock_stream );
	pMsg = RecvMessage( sock_stream );
	CMessageTrash trash2(pMsg);
	if( pMsg->IsFailed() ){}

	//send the file stream
	int nLen = RecvFileEx( sock_stream, strFileName.c_str(), nFileMode );
	closesocket( sock_stream );

	//step 4. exchange the error code.
	msg.Init( NCM_STREAMLENGTH, GetAddr(), GetServAddr(), nLen );
	m_pClntProxy->SendMessage( &msg );

	pMsg = GetMessage( NCF_ACK|NCM_STREAMLENGTH );
	CMessageTrash trash3(pMsg);

	return pMsg->GetResult();
}
开发者ID:EISALab,项目名称:AMGAgroundwater,代码行数:60,代码来源:clntkel.cpp

示例3: DoPassive

HRESULT CClientSession::DoPutFile( const string& strSrcFile, const string& strDstFile )
{
	if( !IsFileExist( strSrcFile.c_str() ) ){
		return E_NOENT;
	}

	//step 1. request passive mode to get the data channel address
	u_int nPasPort = 0;
	HRESULT hRet = DoPassive( nPasPort );
	if( FAILED(hRet) )return hRet;

	//step 2. send the put file command.
	CMessage1Param<char*>* pMsgPut = (CMessage1Param<char*>*)CMessageBase::Alloc( sizeof(CMessageBase)+strDstFile.length()+1 );
	pMsgPut->Init( NCM_PUTFILE, GetAddr(), GetServAddr(), strDstFile.c_str() );
	CMessageTrash trash1(pMsgPut);
	m_pClntProxy->SendMessage( pMsgPut );

	CMessage1Param<int>* pMsgAck = (CMessage1Param<int>*)WaitForMessage( NCF_ACK|NCM_PUTFILE );
	CMessageTrash trash2(pMsgAck);
	if( !pMsgAck->IsSucceeded() )return pMsgAck->GetResult();

	pMsgAck->ntoh( false );
	int nFileMode = pMsgAck->GetParam();

	//step 3. now the server agrees on the file transfer, connect the data channel and send file
	SOCKET sock_stream = OpenStream( nPasPort );
	if( sock_stream==INVALID_SOCKET )return E_OPENSTREAM;

	//open the data stream channel.
/*	CMessageBase msg;
	msg.Init( NCM_OPENSTREAM, GetAddr(), GetServAddr() );
	SendMessage( sock_stream, &msg );
	CMessageBase* pMsg = RecvMessage<CMessageBase>( sock_stream );
	if( pMsg==NULL ){
		closesocket( sock_stream );
		return E_OPENSTREAM;
	}

	CMessageTrash trash3(pMsg);
	if( pMsg->IsFailed() ){
		closesocket( sock_stream );
		return pMsg->GetResult();
	}*/

	//send the file stream
	int nLen = SendFileEx( sock_stream, strSrcFile.c_str(), nFileMode );
	shutdown( sock_stream, SD_BOTH );
	closesocket( sock_stream );

	//step 4. exchange the error code.
	CMessageBase msg;
	msg.Init( NCM_STREAMLENGTH, GetAddr(), GetServAddr(), nLen );
	m_pClntProxy->SendMessage( &msg );

	CMessageBase* pMsg = WaitForMessage( NCF_ACK|NCM_STREAMLENGTH );
	CMessageTrash trash4(pMsg);

	return pMsg->GetResult();
}
开发者ID:EISALab,项目名称:AMGAgroundwater,代码行数:59,代码来源:clntkel.cpp

示例4: SetAddr

TBit* C3D_12401::SetChkBx()
{
        TBit* ChkBx = new TBit[C3DChkBox_Nbr];
        if(MainForm->addr_place == 0){
                SetAddr(&ChkBx[0],C3D_EN);
                SetAddr(&ChkBx[1],C3D_DEMO);
        }else if(MainForm->addr_place == 1){
                GetAddr(&ChkBx[0],"C3D_EN");
                GetAddr(&ChkBx[1],"C3D_DEMO");
        }
        return ChkBx;
}
开发者ID:beaver999,项目名称:mygoodjob,代码行数:12,代码来源:ImgProc_12401.cpp

示例5: ShowLine

/* Let's show requested line(or part of it). */
void ShowLine(int y, int x, int len)
{
	char slbuf[512];
	char *ptr, *scr, *attr;
	int i;
	unsigned char curattr;

	ptr=slbuf+3;
	/* Hack: was used for older version to place 25th string on
	 ** 24th.
	 */
	if (y<25)
		GetAddr(y, x, slbuf);
	else
		GetAddr(24, x, slbuf);
	/* Set some adresses */
	curattr=0;
	scr=VirtualScreen+(y-1)*cols+x-1;
	attr=ScreenAttr+(y-1)*cols+x-1;
	/* Let's proceed with string. */
	for (i=0; i<len; i++)
	{
		/* Attribute has changed ? Let's add codes for changing color */
		if (*attr!=curattr)
		{
			/* Pss has changed ? Let's change pss. */
			if (((*attr)&0x80)!=(curattr&0x80)||(!curattr))
			{
				*ptr++=0x28;
				*ptr++=0x43;
				if (*attr>0x80) *ptr++=0xC1;
				else *ptr++=0xC2;
			}
			/* Color has changed ? Let's change it. */
			if (((*attr)&0x7F)!=(curattr&0x7F))
			{
				*ptr++=0x28;
				*ptr++=0x42;
				if (*attr>0x80) *ptr++=*attr;
				else *ptr++=*attr+0x80;
			}
			curattr=*attr;
		}
		*ptr++=*scr;
		scr++;
		attr++;
	}
	/* Add string to output stream */
	AddScrBuf(slbuf, ptr-slbuf);
}
开发者ID:NickMcConnell,项目名称:OangbandU,代码行数:51,代码来源:main-vme.c

示例6: MailConnect

//********************************************************************
// Name:  MailConnect
// Input:   None
// Output:  None
// Description: Connect to the mail host and receive the welcome message.
// Author/Date:  jcar 20/9/96
// History:
//********************************************************************
int MailConnect()
{

	int res;
	TLS_VARS;


	// Create Socket
	if ((GLOBAL(sc) = socket(PF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET)
		return (FAILED_TO_OBTAIN_SOCKET_HANDLE);

	// Get our own host name
	if (gethostname(GLOBAL(LocalHost), HOST_NAME_LEN))
		return (FAILED_TO_GET_HOSTNAME);

	// Resolve the servers IP
	//if (!isdigit(GLOBAL(MailHost)[0])||!gethostbyname(GLOBAL(MailHost)))
	//{
	//	return (FAILED_TO_RESOLVE_HOST);
	//}

	// Connect to server
	GLOBAL(sock_in).sin_family = AF_INET;
	GLOBAL(sock_in).sin_port = htons(25);
	GLOBAL(sock_in).sin_addr.S_un.S_addr = GetAddr(GLOBAL(MailHost));

	if (connect(GLOBAL(sc), (LPSOCKADDR) & GLOBAL(sock_in), sizeof(GLOBAL(sock_in))))
		return (FAILED_TO_CONNECT);

	// receive Server welcome message
	res = Ack();
	return (res);
}
开发者ID:maiconschelter,项目名称:php-past,代码行数:41,代码来源:sendmail.c

示例7: SetAddr

TBit *Vend_11307::SetChkBx()
{
    TBit *ChkBox = new TBit[VendChkBox_Nbr];
    if (MainForm->addr_place == 0) {
	SetAddr(&ChkBox[0], SSC_VSYNC_EN);	//
	SetAddr(&ChkBox[1], SSC_CLK_NG_EN);	//
	SetAddr(&ChkBox[2], SSC_CLK_STOP_EN);	//
	SetAddr(&ChkBox[3], PP_CHCD);	//
    } else if (MainForm->addr_place == 1) {
	GetAddr(&ChkBox[0], "SSC_VSYNC_EN");
	GetAddr(&ChkBox[1], "SSC_CLK_NG_EN");
	GetAddr(&ChkBox[2], "SSC_CLK_STOP_EN");
	GetAddr(&ChkBox[3], "PP_CHCD");
    }
    return ChkBox;
}
开发者ID:beaver999,项目名称:mygoodjob,代码行数:16,代码来源:Vend_11307.cpp

示例8: Format

std::string VertexProgramDecompiler::Format(const std::string& code)
{
	const std::pair<std::string, std::function<std::string()>> repl_list[] =
	{
		{ "$$", []() -> std::string { return "$"; } },
		{ "$0", std::bind(std::mem_fn(&VertexProgramDecompiler::GetSRC), this, 0) },
		{ "$1", std::bind(std::mem_fn(&VertexProgramDecompiler::GetSRC), this, 1) },
		{ "$2", std::bind(std::mem_fn(&VertexProgramDecompiler::GetSRC), this, 2) },
		{ "$s", std::bind(std::mem_fn(&VertexProgramDecompiler::GetSRC), this, 2) },
		{ "$awm", std::bind(std::mem_fn(&VertexProgramDecompiler::AddAddrRegWithoutMask), this) },
		{ "$am", std::bind(std::mem_fn(&VertexProgramDecompiler::AddAddrMask), this) },
		{ "$a", std::bind(std::mem_fn(&VertexProgramDecompiler::AddAddrReg), this) },

		{ "$t", std::bind(std::mem_fn(&VertexProgramDecompiler::GetTex), this) },

		{ "$fa", [this]()->std::string { return std::to_string(GetAddr()); } },
		{ "$f()", std::bind(std::mem_fn(&VertexProgramDecompiler::GetFunc), this) },
		{ "$ifcond ", [this]() -> std::string
	{
		const std::string& cond = GetCond();
		if (cond == "true") return "";
		return "if(" + cond + ") ";
	}
		},
		{ "$cond", std::bind(std::mem_fn(&VertexProgramDecompiler::GetCond), this) }
	};

	return fmt::replace_all(code, repl_list);
}
开发者ID:cocoddy,项目名称:rpcs3,代码行数:29,代码来源:VertexProgramDecompiler.cpp

示例9: GetAddr

HRESULT CClientSession::DoFileMode( int nFileMode )
{
	CMessageHead msg;
	msg.Init( NCM_PASSIVE, GetAddr(), GetServAddr(), nFileMode );
	m_pClntProxy->SendMessage( &msg );

	CMessageHead* pAck = GetMessage( NCF_ACK|NCM_PASSIVE );
	CMessageTrash trash( pAck );
	return pAck->GetResult();
}
开发者ID:EISALab,项目名称:AMGAgroundwater,代码行数:10,代码来源:clntkel.cpp

示例10: SetAddr

TBit* HSV_12401::SetChkBx()
{
        TBit* ChkBx = new TBit[HSVChkBox_Nbr];
        if(MainForm->addr_place == 0){
                SetAddr(&ChkBx[0],HUE_DEMO);
        }else if(MainForm->addr_place == 1){
                GetAddr(&ChkBx[0],"HUE_DEMO");
        }
        return ChkBx;
}
开发者ID:beaver999,项目名称:mygoodjob,代码行数:10,代码来源:ImgProc_12401.cpp

示例11: sizeof

HRESULT CClientSession::DoChMod( const string& strFileName, int nMode )
{
	CMessage1Param<char*>* pMsg = (CMessage1Param<char*>*)CMessageBase::Alloc( sizeof(CMessageBase)+strFileName.length()+1 );
	pMsg->Init( NCM_CHMOD, GetAddr(), GetServAddr(), strFileName.c_str(), nMode );
	CMessageTrash trash(pMsg);

	m_pClntProxy->SendMessage( pMsg );
	CMessageBase* pAck = WaitForMessage( NCF_ACK|NCM_CHMOD );
	CMessageTrash trash2(pAck);
	return pAck->GetResult();
}
开发者ID:EISALab,项目名称:AMGAgroundwater,代码行数:11,代码来源:clntkel.cpp

示例12: configure

inline void configure()
{
	uint8_t addr = GetAddr();
  // Initialize SMBus
   SMBusInit(addr);
  SMBEnable();

  conf_TMR0();
  conf_motors();

  SREG |= _BV(7); /* Enable interrupts */
}
开发者ID:thomma,项目名称:VTMotor,代码行数:12,代码来源:main.c


注:本文中的GetAddr函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。