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


C++ GetSocket函数代码示例

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


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

示例1: SetIpRecvTTL

bool Socket::SetIpRecvTTL(bool x)
{
	int optval = x ? 1 : 0;
	if (setsockopt(GetSocket(), IPPROTO_IP, IP_RECVTTL, (char *)&optval, sizeof(optval)) == -1)
	{
		Handler().LogError(this, "setsockopt(IPPROTO_IP, IP_RECVTTL)", Errno, StrError(Errno), LOG_LEVEL_FATAL);
		return false;
	}
	return true;
}
开发者ID:Omniasoft,项目名称:BellPi,代码行数:10,代码来源:Socket.cpp

示例2: GetSocket

BOOL CXMMTCtrl::SendCode(short nIndex, short bCode) 
{
	if( bCode == CODE_CUSTOMSESSION ) return FALSE;
	int r = FALSE;
	CCSocket *pSocket = GetSocket(nIndex);
	if( pSocket ){
		BYTE b = BYTE(bCode);
		r = SendBuf(pSocket, &b, sizeof(b));
	}
	return r;
}
开发者ID:ja7ude,项目名称:XMMT,代码行数:11,代码来源:XMMTCtl.cpp

示例3: sizeof

bool ConnectionDescriptor::GetPeername (struct sockaddr *s)
{
	bool ok = false;
	if (s) {
		socklen_t len = sizeof(*s);
		int gp = getpeername (GetSocket(), s, &len);
		if (gp == 0)
			ok = true;
	}
	return ok;
}
开发者ID:alltom,项目名称:easyget,代码行数:11,代码来源:ed.cpp

示例4: ReConnectAsync

int32_t CSSLClientAsync::ReConnectAsync()
{
    int32_t nErrorCode = 0;
    if (S_INVALID_SOCKET == GetSocket())
    {
        _InitSocket();
        InitSSL(GetCertFile().c_str(), GetKeyFile().c_str(), GetKeyPassword().c_str());
        nErrorCode = ConnectAsync(GetRemoteIP(), GetRemotePort());
    }
    return nErrorCode;
}
开发者ID:shiwei0124,项目名称:common_code,代码行数:11,代码来源:ssl_client_async.cpp

示例5: UnInitSSL

void CSSLClientAsync::_Close()
{
    if (m_ssl)
    {
        UnInitSSL();
    }
    if (GetSocket() != S_INVALID_SOCKET)
    {
        if (m_pio)
        {
            m_pio->Remove_Handler(this);
        }
        SetSSLConnectStatus(FALSE);
        S_CloseSocket(GetSocket());
        SOCKET_IO_WARN("close ssl socket, sock %d, real sock: %d.", GetSocketID(), GetSocket());
        m_socket = S_INVALID_SOCKET;
        DoClose(GetSocketID());
        _ClearSendBuffer();
    }
}
开发者ID:shiwei0124,项目名称:common_code,代码行数:20,代码来源:ssl_client_async.cpp

示例6: Attach

bool UdpSocket::Open(SocketAddress& ad)
{
	if (GetSocket() == INVALID_SOCKET)
	{
		Attach(CreateSocket(ad.GetFamily(), SOCK_DGRAM, "udp"));
	}
	if (GetSocket() != INVALID_SOCKET)
	{
		SetNonblocking(true);
		if (connect(GetSocket(), ad, ad) == -1)
		{
			Handler().LogError(this, "connect", Errno, StrError(Errno), LOG_LEVEL_FATAL);
			SetCloseAndDelete();
			return false;
		}
		SetConnected();
		return true;
	}
	return false;
}
开发者ID:f059074251,项目名称:interested,代码行数:20,代码来源:UdpSocket.cpp

示例7: GetSocket

///////////////////////////////////////////////////////////////////////////////
/// @fn CConnection::Stop
/// @description Stops the socket and cancels the timeout timer. Does not
///   need to be called on a listening connection (ie one that has had
///   Start() called on it.
/// @pre Any initialized CConnection object.
/// @post The underlying socket is closed and the message timeout timer is
///        cancelled.
///////////////////////////////////////////////////////////////////////////////
void CConnection::Stop()
{
    Logger.Debug << __PRETTY_FUNCTION__ << std::endl;
    ProtocolMap::iterator sit;
    for(sit = m_protocols.begin(); sit != m_protocols.end(); sit++)
    {
        (*sit).second->Stop();
    }   
    Logger.Debug << __PRETTY_FUNCTION__ << std::endl;
    GetSocket().close();
}
开发者ID:akella84,项目名称:FREEDM,代码行数:20,代码来源:CConnection.cpp

示例8: sizeof

/** Returns local port number for bound socket file descriptor. */
port_t Socket::GetSockPort()
{
#ifdef ENABLE_IPV6
#ifdef IPPROTO_IPV6
	if (IsIpv6())
	{
		struct sockaddr_in6 sa;
		socklen_t sockaddr_length = sizeof(struct sockaddr_in6);
		if (getsockname(GetSocket(), (struct sockaddr *)&sa, (socklen_t*)&sockaddr_length) == -1)
			memset(&sa, 0, sizeof(sa));
		return ntohs(sa.sin6_port);
	}
#endif
#endif
	struct sockaddr_in sa;
	socklen_t sockaddr_length = sizeof(struct sockaddr_in);
	if (getsockname(GetSocket(), (struct sockaddr *)&sa, (socklen_t*)&sockaddr_length) == -1)
		memset(&sa, 0, sizeof(sa));
	return ntohs(sa.sin_port);
}
开发者ID:amirkrifa,项目名称:BitHoc,代码行数:21,代码来源:socket.cpp

示例9: memset

/**	@fn	HPR_INT32 CTCPClient::Connect(const char* szIP, HPR_INT32 nPort)
*	@brief 
*	@param[in] szIP 
*	@param[in] nPort 
*	@return	
*/
HPR_INT32 CTCPClient::Connect( const char* szIP, HPR_INT32 nPort )
{
	HPR_INT32 nErrorCode = LIB_DEV_PROXY_ERROR_OK;
	HPR_ADDR_T addr;
	memset(&addr, 0, sizeof(HPR_ADDR_T));
	HPR_MakeAddrByString(AF_INET, szIP, nPort, &addr);
	if (HPR_ConnectWithTimeOut(GetSocket(), &addr, 5000) != 0)
	{
		nErrorCode = LIB_DEV_PROXY_ERROR_CONNECT;
	}
	return nErrorCode;
}
开发者ID:Strongc,项目名称:util_code,代码行数:18,代码来源:tcp_client.cpp

示例10: GetSocket

void CItem::StopTimerBasedOnWearExpireEvent()
{
	if (!m_pkTimerBasedOnWearExpireEvent)
		return;

	int remain_time = GetSocket(ITEM_SOCKET_REMAIN_SEC) - event_processing_time(m_pkTimerBasedOnWearExpireEvent) / passes_per_sec;

	SetSocket(ITEM_SOCKET_REMAIN_SEC, remain_time);
	event_cancel(&m_pkTimerBasedOnWearExpireEvent);

	ITEM_MANAGER::instance().SaveSingleItem(this);
}
开发者ID:ronniwe,项目名称:Varios,代码行数:12,代码来源:item.cpp

示例11: Handler

/** send to connected address */
void UdpSocket::SendBuf(const char *data, size_t len, int flags)
{
	if (!IsConnected())
	{
		Handler().LogError(this, "SendBuf", 0, "not connected", LOG_LEVEL_ERROR);
		return;
	}
	if ((m_last_size_written = send(GetSocket(), data, (int)len, flags)) == -1)
	{
		Handler().LogError(this, "send", Errno, StrError(Errno), LOG_LEVEL_ERROR);
	}
}
开发者ID:f059074251,项目名称:interested,代码行数:13,代码来源:UdpSocket.cpp

示例12: OnLine

    void OnLine(const std::string& line) {
#ifdef ENABLE_DETACH
        if (g_b_detach2 && !IsDetach())
        {
            m_line = line;
            if (!Detach())
            {
                fprintf(stderr, "\nDetach failed\n");
            }
            return;
        }
        DEB(printf("fd %d OnLine; %s\n", GetSocket(), Handler().IsSlave() ? "slave" : "master");)
开发者ID:JerkWisdom,项目名称:zpublic,代码行数:12,代码来源:echoserver.cpp

示例13: resolver

	void Client::Connect(const std::string& ip, int port)
	{
		tcp::resolver resolver(ioService);
		tcp::resolver::query query(ip, std::to_string(port));

		auto endpointIt = resolver.resolve(query);

		boost::system::error_code ec;

		auto newConn = Connection::create(ioService);
		boost::asio::async_connect(newConn->GetSocket(), endpointIt, std::bind(&Client::OnConnect, this, newConn, _1, _2));
	}
开发者ID:skyser2003,项目名称:FG-Network,代码行数:12,代码来源:FGClient.cpp

示例14: GetSocket

///////////////////////////////////////////////////////////////////////////////
/// CConnection::HandleResend
/// @description: After being called, this method sends up WINDOWSIZE messages
///   to retry delievery.
/// @pre: Initialized CConnection.
/// @post: Upto WINDOWSIZE messages are rewritten to the channel.
///////////////////////////////////////////////////////////////////////////////
void CConnection::HandleResend()
{
    Logger::Debug << __PRETTY_FUNCTION__ << std::endl;
    SlidingWindow<QueueItem>::iterator sit;
    sit = m_queue.begin();   
 
    for(unsigned int i=0; sit != m_queue.end() && i < GetWindowSize(); i++,sit++ )
    {
        GetSocket().get_io_service().post(
        boost::bind(&CConnection::HandleSend, this,(*sit).second));
    }
}
开发者ID:lfqt5,项目名称:FREEDM,代码行数:19,代码来源:CConnection.cpp

示例15: NetIoBuffer

bool NetSocket::PostRecv()
{
    _netStatus.fetch_or(NET_STATUS_RECV_PENDING);

    NetIoBuffer* recvOP = new NetIoBuffer(NetCompletionOP::OP_READ);
    recvOP->Reset(GetSocket());

    MemoryBlock* buffer = recvOP->Alloc(MAX_PACKET_SIZE);

    WSABUF wbuf;
    wbuf.buf = buffer->GetData();
    wbuf.len = buffer->GetDataLen();

    DWORD flags = 0;
    int rc = WSARecv(
        GetSocket(),
        &wbuf,
        1,
        NULL,
        &flags,
        &(recvOP->ol),
        NULL
    );

    if (rc == SOCKET_ERROR)
    {
        int error = WSAGetLastError();
        if (error != WSA_IO_PENDING)
        {
            delete recvOP;

            DebugPrint("PostRecv: WSARecv* failed: %s", SocketGetErrorString(error).c_str());
            Disconnect(NET_CTYPE_SYSTEM);

            return false;
        }
    }

    return true;
}
开发者ID:goopymoon,项目名称:RefLib,代码行数:40,代码来源:reflib_net_socket.cpp


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