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


C++ SocketAddress::GetSize方法代码示例

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


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

示例1: assert

bool
SocketDescriptor::Connect(SocketAddress address)
{
  assert(address.IsDefined());

  return ::connect(Get(), address.GetAddress(), address.GetSize()) >= 0;
}
开发者ID:piermariamattioli,项目名称:XCSoar,代码行数:7,代码来源:SocketDescriptor.cpp

示例2: ReceiveFrom

int UDPSocket::ReceiveFrom( void* inToReceive, int inMaxLength, SocketAddress& outFromAddress )
{
	socklen_t fromLength = outFromAddress.GetSize();
	
	int readByteCount = recvfrom( mSocket,
								 static_cast< char* >( inToReceive ),
								 inMaxLength,
								 0, &outFromAddress.mSockAddr, &fromLength );
	if( readByteCount >= 0 )
	{
		return readByteCount;
	}
	else
	{
		int error = SocketUtil::GetLastError();
		
		if( error == WSAEWOULDBLOCK )
		{
			return 0;
		}
		else if( error == WSAECONNRESET )
		{
			//this can happen if a client closed and we haven't DC'd yet.
			//this is the ICMP message being sent back saying the port on that computer is closed
			LOG( "Connection reset from %s", outFromAddress.ToString().c_str() );
			return -WSAECONNRESET;
		}
		else
		{
			SocketUtil::ReportError( "UDPSocket::ReceiveFrom" );
			return -error;
		}
	}
}
开发者ID:Resinderate,项目名称:ShadowMultiplayer,代码行数:34,代码来源:UDPSocket.cpp

示例3: Bind

int UDPSocket::Bind( const SocketAddress& inBindAddress )
{
	int error = bind( mSocket, &inBindAddress.mSockAddr, inBindAddress.GetSize() );
	if( error != 0 )
	{
		SocketUtil::ReportError( "UDPSocket::Bind" );
		return SocketUtil::GetLastError();
	}
	
	return NO_ERROR;
}
开发者ID:Resinderate,项目名称:ShadowMultiplayer,代码行数:11,代码来源:UDPSocket.cpp

示例4: Bind

        int UDPSocket::Bind(const SocketAddress& address)
        {
			int error = bind(m_socket, &address.m_sockAddr, (int)address.GetSize());
            if(error != 0)
            {
#ifdef _DEBUG
                ReportError("UDPSocket::Bind");                
#endif
                return LastError(); 
            }

            return NO_ERROR;
        }
开发者ID:manhunterita,项目名称:HatchitNetwork,代码行数:13,代码来源:ht_udpsocket.cpp

示例5: ReceiveFrom

        int UDPSocket::ReceiveFrom(void* buffer, int len, SocketAddress& from)
        {
            socklen_t fromLen = (socklen_t)from.GetSize();
            int byteCount = recvfrom(m_socket, static_cast<char*>(buffer), len, 0, &from.m_sockAddr, &fromLen);
            if(byteCount < 0)
            {
#ifdef _DEBUG
                ReportError("UDPSocket::ReceiveFrom");
#endif
                return -LastError();
            }

            return byteCount;
        }
开发者ID:manhunterita,项目名称:HatchitNetwork,代码行数:14,代码来源:ht_udpsocket.cpp

示例6:

ssize_t
SocketDescriptor::Write(const void *buffer, size_t length,
                        SocketAddress address)
{
  int flags = 0;
#ifdef HAVE_POSIX
  flags |= MSG_DONTWAIT;
#endif
#ifdef __linux__
  flags |= MSG_NOSIGNAL;
#endif

  return ::sendto(Get(), (const char *)buffer, length, flags,
                  address.GetAddress(), address.GetSize());
}
开发者ID:piermariamattioli,项目名称:XCSoar,代码行数:15,代码来源:SocketDescriptor.cpp

示例7: SendTo

int UDPSocket::SendTo( const void* inToSend, int inLength, const SocketAddress& inToAddress )
{
	int byteSentCount = sendto( mSocket,
							   static_cast< const char* >( inToSend ),
							   inLength,
							   0, &inToAddress.mSockAddr, inToAddress.GetSize() );
	if( byteSentCount <= 0 )
	{
		//we'll return error as negative number to indicate less than requested amount of bytes sent...
		SocketUtil::ReportError( "UDPSocket::SendTo" );
		return -SocketUtil::GetLastError();
	}
	else
	{
		return byteSentCount;
	}
}
开发者ID:Resinderate,项目名称:ShadowMultiplayer,代码行数:17,代码来源:UDPSocket.cpp

示例8: SendTo

        int UDPSocket::SendTo(const void* data, int len, const SocketAddress& to)
        {
			int byteCount = sendto(m_socket, static_cast<const char*>(data), len, 0, &to.m_sockAddr, (int)to.GetSize());
            if(byteCount < 0)
            {
#ifdef _DEBUG
                ReportError("UDPSocket::SendTo");
#endif
                return -LastError();
            }

            return byteCount;
        }
开发者ID:manhunterita,项目名称:HatchitNetwork,代码行数:13,代码来源:ht_udpsocket.cpp

示例9: bind

bool
SocketDescriptor::Bind(SocketAddress address)
{
  return bind(Get(), address.GetAddress(), address.GetSize()) == 0;
}
开发者ID:piermariamattioli,项目名称:XCSoar,代码行数:5,代码来源:SocketDescriptor.cpp


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