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


C++ TInetAddr::Port方法代码示例

本文整理汇总了C++中TInetAddr::Port方法的典型用法代码示例。如果您正苦于以下问题:C++ TInetAddr::Port方法的具体用法?C++ TInetAddr::Port怎么用?C++ TInetAddr::Port使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TInetAddr的用法示例。


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

示例1:

enum TVerdict CEsockTest19_1::easyTestStepL()
	{
	TInetAddr addr;
	TBuf<39> buf;
	
	// setting the IP address
	
	const TIp6Addr KInet6Addr19_1 = {{{0xff,0xfe,0,0,0,0,0,0,0,0,0,0,0,0,0x29,0xfe}}};
	const TIp6Addr KInet6Addr19_2 = {{{0xff,0xf1,0,1,0,1,0,1,0,1,0,1,0,1,0x29,0xff}}};
	
	// setting the IP address
	
	// set the address
	addr.SetAddress(KInet6Addr19_1);
	
	// check it has been set correctly
	addr.OutputWithScope(buf);
	TESTL(buf==_L("fffe::29fe"));
	
	// check port number initialised to 0
	TESTL(addr.Port()==0);
	
	// change the address
	addr.SetAddress(KInet6Addr19_2);
	
	// check it has been set correctly
	addr.OutputWithScope(buf);
	TESTL(buf==_L("fff1:1:1:1:1:1:1:29ff"));
	
	// check port number is still set to 0
	TESTL(addr.Port()==0);
	
	return EPass;
	}
开发者ID:cdaffara,项目名称:symbiandump-os1,代码行数:34,代码来源:EsockTestSection19.cpp

示例2: tcp_conn_handler

/**
 * Handle incoming connects
 */
void tcp_sock::tcp_conn_handler()
{
	if (!ctc) {
		DEBUG_WARNING("conn handler: no pending socket\n");
	}

	TInetAddr ia;
	struct sa peer;
	ctc->iSocket.RemoteName(ia);
	sa_set_in(&peer, ia.Address(), ia.Port());

	DEBUG_INFO("conn handler: incoming connect from %J\n", &peer);

	ctc->blank = false;

	/*
	 * Application handler might call tcp_accept(), tcp_reject()
	 * or do nothing
	 */
	if (connh)
		connh(&peer, arg);

	if (ctc) {
		DEBUG_INFO("delete ctc\n");
		delete ctc;
		ctc = NULL;
	}

	/* Create blank socket for the next incoming CONNECT */
	blank_socket();

	cts->Accepting();
}
开发者ID:anchowee,项目名称:traversal_server,代码行数:36,代码来源:tcp.cpp

示例3:

TSAHostCacheEntry::TSAHostCacheEntry(const TInetAddr& aAddress, TInt aQuality)
{
	iPort = aAddress.Port();
	iAddress = aAddress.Address();

	iQuality = aQuality;
}
开发者ID:imrekel,项目名称:Symella,代码行数:7,代码来源:SAHostCacheEntry.cpp

示例4: SendDataL

TInt CUdpProcess::SendDataL(TDes8& aData, TInetAddr& aAddr, TInt aSize)
    /**
      Send data.
      @return the size of data sent
      */
{
    TRequestStatus status;
    
    TInt port = aAddr.Port();
    iConsole.Printf(_L("Before sending, size = %d, port=%d\n"), aSize, port);
    TSockXfrLength sendSize = 0; //aSize;
    iSocket.SendTo(aData, aAddr, 0, status, sendSize);
    User::WaitForRequest(status);
    iConsole.Printf(_L("Sending result = %d, and sent=%d\n"), status.Int(), sendSize());

    switch(status.Int())
    {
    case KErrEof:
        iConsole.Printf(_L("Connection closed!"));
        return 0;       
    case KErrNone:
        iConsole.Printf(_L("Send successfully.\n"));
        break;
    default:
        User::LeaveIfError(status.Int());
        break;
    }
    return sendSize();
}
开发者ID:cdaffara,项目名称:symbiandump-os2,代码行数:29,代码来源:tcptest.cpp

示例5: silc_net_get_remote_port

SilcUInt16 silc_net_get_remote_port(SilcSocket sock)
{
  SilcSymbianSocket *s = (SilcSymbianSocket *)sock;
  TInetAddr addr;

  s->sock->RemoteName(addr);
  return (SilcUInt16)addr.Port();
}
开发者ID:FabrizioFabbe,项目名称:runtime,代码行数:8,代码来源:silcsymbiannet.cpp

示例6: silc_net_get_local_port

SilcUInt16 silc_net_get_local_port(SilcSocket sock)
{
  SilcSymbianSocket *s = (SilcSymbianSocket *)sock;
  TInetAddr addr;

  s->sock->LocalName(addr);
  return (SilcUInt16)addr.Port();
}
开发者ID:FabrizioFabbe,项目名称:runtime,代码行数:8,代码来源:silcsymbiannet.cpp

示例7: local_get

int udp_sock::local_get(struct sa *local) const
{
	TInetAddr ia;

	cus->iSocket.LocalName(ia);
	sa_set_in(local, ia.Address(), ia.Port());

	return 0;
}
开发者ID:ClearwaterCore,项目名称:libre-upstream,代码行数:9,代码来源:udp.cpp

示例8: net_if_getaddr4

/**
 * Get the local IP address of the device
 *
 * @note Requires at least one IP packet sent in advance!
 */
int net_if_getaddr4(const char *ifname, int af, struct sa *ip)
{
	(void)ifname;

	if (AF_INET != af)
		return EAFNOSUPPORT;

	/* Already cached? */
	if (sa_isset(&local_ip, SA_ADDR)) {
		sa_cpy(ip, &local_ip);
		return 0;
	}

	RSocketServ ss;
	RSocket s;
	TInt ret;

	ret = ss.Connect();
	if (KErrNone != ret) {
		DEBUG_WARNING("connecting to socket server fail (ret=%d)\n",
			      ret);
		return ECONNREFUSED;
	}

	ret = s.Open(ss, KAfInet, KSockDatagram, KProtocolInetUdp);
	if (KErrNone != ret) {
		DEBUG_WARNING("open socket failed (ret=%d)\n", ret);
		return ECONNREFUSED;
	}

	TInetAddr bind;
	bind.SetPort(0);
	bind.SetAddress(KInetAddrAny);

	ret = s.Bind(bind);
	if (KErrNone != ret) {
		DEBUG_WARNING("bind socket failed (ret=%d)\n", ret);
		return ECONNREFUSED;
	}

	TInetAddr local;
	s.LocalName(local);

	s.Close();
	ss.Close();

	sa_set_in(&local_ip, local.Address(), local.Port());

	DEBUG_NOTICE("local IP addr: %j\n", &local_ip);

	if (!sa_isset(&local_ip, SA_ADDR))
		return EINVAL;

	sa_cpy(ip, &local_ip);

	return 0;
}
开发者ID:ClearwaterCore,项目名称:libre-upstream,代码行数:62,代码来源:snet.cpp

示例9: tcp_sock_local_get

int tcp_sock_local_get(const struct tcp_sock *ts, struct sa *local)
{
	if (!ts || !local)
		return EINVAL;

	TInetAddr ia;
	ts->cts->iSocket.LocalName(ia);
	sa_set_in(local, ia.Address(), ia.Port());

	return 0;
}
开发者ID:anchowee,项目名称:traversal_server,代码行数:11,代码来源:tcp.cpp

示例10: tcp_conn_peer_get

int tcp_conn_peer_get(const struct tcp_conn *tc, struct sa *peer)
{
	if (!tc || !peer)
		return EINVAL;

	TInetAddr ia;
	tc->ctc->iSocket.RemoteName(ia);
	sa_set_in(peer, ia.Address(), ia.Port());

	return 0;
}
开发者ID:anchowee,项目名称:traversal_server,代码行数:11,代码来源:tcp.cpp

示例11: tcp_conn_local_get

int tcp_conn_local_get(const struct tcp_conn *tc, struct sa *local)
{
	if (!tc || !local)
		return EINVAL;

	TInetAddr ia;
	tc->ctc->iSocket.LocalName(ia);
	sa_set_in(local, ia.Address(), ia.Port());

	return 0;
}
开发者ID:anchowee,项目名称:traversal_server,代码行数:11,代码来源:tcp.cpp

示例12: ILibSocketWrapper_recvfrom

int ILibSocketWrapper_recvfrom(int socketObject, char *buffer, int bufferLength, struct sockaddr *src)
{
	RSocket *s = (RSocket*)SocketArray[socketObject];
	TRequestStatus status;
	TInetAddr addr;
	int RetVal=0;
	RBuf8 *buf = new RBuf8();
	
	if(buf->Create(bufferLength)==KErrNone)
	{
		TProtocolDesc aProtocol;
		
		s->Info(aProtocol);
		if(aProtocol.iSockType==KSockStream)
		{
			s->RemoteName(addr);
			((struct in_addr*)src->sa_data)->s_addr = ntohl(addr.Address());
			src->sa_port = htons(addr.Port());
			RetVal = ILibSocketWrapper_recv(socketObject, buffer, bufferLength);
		}
		else
		{
			s->RecvFrom(*buf,addr,(unsigned int)0,status);
			User::WaitForRequest(status);
			if(status!=KErrNone)
			{
				RetVal = 0;
			}
			else
			{
				((struct in_addr*)src->sa_data)->s_addr = ntohl(addr.Address());
				src->sa_port = htons(addr.Port());
				Mem::Copy(buffer,buf->Ptr(),buf->Length());
				RetVal = buf->Length();
			}
		}
	}
	buf->Close();
	delete buf;
	return(RetVal);
}
开发者ID:GufCab,项目名称:Semester-Projekt---Test-Kode,代码行数:41,代码来源:ILibSocketWrapper.cpp

示例13: Compare

MFactoryQuery::TMatchResult THttpClientFlowQuery::Compare(TFactoryObjectInfo& aFactoryObjectInfo )
	{
	const CHttpClientFlow* flow = static_cast<const CHttpClientFlow*>(aFactoryObjectInfo.iInfo.iFactoryObject);
	
	// iClientFlags == ECreateNew is handled by factory, other needs to be checked here	
 	TInetAddr remName;
   	flow->RemName( remName );
  	if ( remName.Address ( ) == iSockAddr.iAddr && remName.Port ( ) ==  iSockAddr.iPort && flow->Status( ) == KErrNone )
		{
		return MFactoryQuery::EMatch;
		}
	return MFactoryQuery::EContinue;
	}
开发者ID:cdaffara,项目名称:symbiandump-mw4,代码行数:13,代码来源:upnp_cf_msgs.cpp

示例14: ILibSocketWrapper_getsockname

int ILibSocketWrapper_getsockname(int socketObject, struct sockaddr* local, int* length)
{
  struct sockaddr_in* localAddr = (struct sockaddr_in*)local;
	RSocket *s = (RSocket*)SocketArray[socketObject];
  TInetAddr sockAddr;

  // get the local name
  s->LocalName(sockAddr);

  // convert from Symbian
  localAddr->sin_family = sockAddr.Family();
  localAddr->sin_port = sockAddr.Port();
  localAddr->sin_addr.s_addr = ntohl(sockAddr.Address());
  
  return 0;
}
开发者ID:GufCab,项目名称:Semester-Projekt---Test-Kode,代码行数:16,代码来源:ILibSocketWrapper.cpp

示例15: SetAddress

void CFTPResolver::SetAddress(TInetAddr& aAddress)
{
	// Get the 1st entry resolved
	iNameRecord = iNameEntry();
	// Save the address (take care not to overwrite the port, might have been already set)
	if (TInetAddr::Cast(iNameRecord.iAddr).Family() == KAfInet)
		aAddress.SetAddress(TInetAddr::Cast(iNameRecord.iAddr).Address());
	else
		aAddress.SetAddress(TInetAddr::Cast(iNameRecord.iAddr).Ip6Address());

#if defined(__FTPPROTDEBUG__)
	TBuf<512> debugBuffer; // A Buffer to output the resolved IP 
	
	aAddress.Output(debugBuffer);
	debugBuffer.Append(_L(","));
	debugBuffer.AppendNum(aAddress.Port(), EDecimal); 
	debugBuffer.Append(_L("\n"));
#endif
	FTPPROTDEBUG(_DBGResolver,_L("Resolved address is:"));
	FTPPROTDEBUG(_DBGResolver,debugBuffer);
}
开发者ID:kuailexs,项目名称:symbiandump-mw2,代码行数:21,代码来源:RESOLVER.CPP


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