• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ Handler函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: Handler

bool Socket::SetSoKeepalive(bool x)
{
#ifdef SO_KEEPALIVE
	int optval = x ? 1 : 0;
	if (setsockopt(GetSocket(), SOL_SOCKET, SO_KEEPALIVE, (char *)&optval, sizeof(optval)) == -1)
	{
		Handler().LogError(this, "setsockopt(SOL_SOCKET, SO_KEEPALIVE)", Errno, StrError(Errno), LOG_LEVEL_FATAL);
		return false;
	}
	return true;
#else
	Handler().LogError(this, "socket option not available", 0, "SO_KEEPALIVE", LOG_LEVEL_INFO);
	return false;
#endif
}
开发者ID:amirkrifa,项目名称:BitHoc,代码行数:15,代码来源:socket.cpp


示例2: Handler

bool Socket::SetSoBroadcast(bool x)
{
#ifdef SO_BROADCAST
	int optval = x ? 1 : 0;
	if (setsockopt(GetSocket(), SOL_SOCKET, SO_BROADCAST, (char *)&optval, sizeof(optval)) == -1)
	{
		Handler().LogError(this, "setsockopt(SOL_SOCKET, SO_BROADCAST)", Errno, StrError(Errno), LOG_LEVEL_FATAL);
		return false;
	}
	return true;
#else
	Handler().LogError(this, "socket option not available", 0, "SO_BROADCAST", LOG_LEVEL_INFO);
	return false;
#endif
}
开发者ID:a4a881d4,项目名称:oai,代码行数:15,代码来源:Socket.cpp


示例3: logdetail

void ControlSocket::OnAccept(void)
{
    logdetail("ControlSocket: Incoming connection from %s:%u [host:%s]",GetRemoteAddress().c_str(),GetRemotePort(),GetRemoteHostname().c_str());

    // must perform some crappy ptr conversion here, doesnt want to typecast SocketHandler -> ControlSocketHandler directly
    SocketHandler& hnd = Handler();
    ControlSocketHandler *chnd = static_cast<ControlSocketHandler*>(&hnd);
    _instance = chnd->GetInstance();
    DEBUG(logdebug("ControlSocket: setting instance = %X",_instance));

    // accept only connections from one host for now, if set
    if(_instance->GetConf()->rmcontrolhost.length()
        && !(GetRemoteAddress() == _instance->GetConf()->rmcontrolhost || GetRemoteHostname() == _instance->GetConf()->rmcontrolhost))
    {
        logdetail("ControlSocket: connection rejected. closing.");
        SetCloseAndDelete(true);
        return;
    }

    SendTelnetText(_instance->GetScripts()->variables.Get("@version"));
    if(_instance->GetConf()->rmcontrolpass.size())
    {
        SendTelnetText("Authentication?");
    }

    _ok = true;
}
开发者ID:Cyph3r,项目名称:pseuwow,代码行数:27,代码来源:ControlSocket.cpp


示例4: requestRouterState

	AsyncValue<Handler> Server::routeDynamicRequestFromFile(String path) {
		auto lp=mgr->loadPage(*p,root,path);
		if(lp) return Handler(&dynamicHandler,lp());
		requestRouterState* st=new requestRouterState();
		lp.wait(st);
		return Future<Handler>(&st->cb);
	}
开发者ID:Dinesh-Ramakrishnan,项目名称:workspace,代码行数:7,代码来源:server.C


示例5: interval

int
Input_Task::add_timer (void *argument)
{
  u_long useconds = *reinterpret_cast<int *> (argument);
  ACE_Time_Value interval (useconds / usecs_,
                           useconds % usecs_);
  ACE_Time_Value expire_at = ACE_OS::gettimeofday () + interval;

  Handler *h;

  ACE_NEW_RETURN (h,
                  Handler (expire_at),
                  -1);

  int id = queue_->schedule (h, 0, expire_at);

  if (id == -1)
    ACE_ERROR_RETURN ((LM_ERROR,
                       "schedule failed"),
                      -1);

  // We store the id into the handler, this is only used to produce
  // nicer messages.
  h->set_id (id);

  ACE_OS::printf ("scheduling timer %d\n",
                  id);
  return 0;
}
开发者ID:asdlei00,项目名称:ACE,代码行数:29,代码来源:Thread_Timer_Queue_Test.cpp


示例6: sctp_recvmsg

void SctpSocket::OnRead()
{
/*
	int sctp_recvmsg(int sd, void * msg, size_t * len,
		struct sockaddr * from, socklen_t * fromlen,
		struct sctp_sndrcvinfo * sinfo, int * msg_flags);

	DESCRIPTION
	sctp_recvmsg  is  a  wrapper library function that can be used to receive a message from a socket while using the advanced
	features of SCTP.  sd is the socket descriptor on which the message pointed to by msg of length len is received.

	If from is not NULL, the source address of the message is filled in. The argument fromlen  is  a  value-result  parameter.
	initialized  to  the  size  of the buffer associated with from , and modified on return to indicate the actual size of the
	address stored.

	sinfo is a pointer to a sctp_sndrcvinfo structure to be filled upon receipt of the message.  msg_flags is a pointer  to  a
	integer that is filled with any message flags like MSG_NOTIFICATION or MSG_EOR.

*/
	struct sockaddr sa;
	socklen_t sa_len = 0;
	struct sctp_sndrcvinfo sinfo;
	int flags = 0;
	int n = sctp_recvmsg(GetSocket(), m_buf, SCTP_BUFSIZE_READ, &sa, &sa_len, &sinfo, &flags);
	if (n == -1)
	{
		Handler().LogError(this, "SctpSocket", Errno, StrError(Errno), LOG_LEVEL_FATAL);
		SetCloseAndDelete();
	}
	else
	{
		OnReceiveMessage(m_buf, n, &sa, sa_len, &sinfo, flags);
	}
}
开发者ID:BornHunter,项目名称:CGSF,代码行数:34,代码来源:SctpSocket.cpp


示例7: Handler

void HttpPutSocket::SetFile(const std::string& file)
{
	//struct stat st;
	
	// Added by Amir Krifa
	std::ifstream f;
	f.open(file.c_str(), std::ios_base::binary | std::ios_base::in);
	//if (!f.good() || f.eof() || !f.is_open()) { return 0; }
	
	if (!f.good() || f.eof() || !f.is_open()) 
	{ 
		Handler().LogError(this, "SetFile", Errno, StrError(Errno), LOG_LEVEL_FATAL);
		SetCloseAndDelete();
	}else
	{
		f.seekg(0, std::ios_base::beg);
		std::ifstream::pos_type begin_pos = f.tellg();
		f.seekg(0, std::ios_base::end);
		m_filename = file;
		m_content_length = static_cast<off_t>(f.tellg() - begin_pos);
	}
	
	//if (!stat(file.c_str(), &st))
	//{
	//	m_filename = file;
	//	m_content_length = st.st_size;
	//}
	//else
	//{
	//	Handler().LogError(this, "SetFile", Errno, StrError(Errno), LOG_LEVEL_FATAL);
	//	SetCloseAndDelete();
	//}
}
开发者ID:amirkrifa,项目名称:BitHoc,代码行数:33,代码来源:HttpPutSocket.cpp


示例8: read

void StdinLine::OnRead()
{
	char buf[m_bufsize];
	int n = read(GetSocket(), buf, m_bufsize - 1); //recv(0, buf, 1000, 0);
	if (n == -1)
	{
		Handler().LogError(this, "OnRead", errno, strerror(errno), LOG_LEVEL_FATAL);
		SetCloseAndDelete();
		return;
	}
	for (size_t i = 0; i < (size_t)n; i++)
	{
		switch (buf[i])
		{
		case 13: // ignore
			break;
		case 10:
			OnLine(m_line);
			m_line = "";
			break;
		default:
			m_line += buf[i];
		}
	}
}
开发者ID:andhikanugraha,项目名称:tetembakan,代码行数:25,代码来源:StdinLine.cpp


示例9: OnEvent

	void OnEvent(int id) {
		if (id != m_id)
		{
			printf("ID MISMATCH!\n");
			exit(-1);
		}
		if (!quit)
		{
			lSocket *p = new lSocket(Handler());
			p -> SetDeleteByHandler();
			p -> Open(HOST, PORT);
			Handler().Add(p);
		}
		static_cast<evHandler&>(Handler()).SetQuit( quit );
		SetCloseAndDelete();
	}
开发者ID:Omniasoft,项目名称:BellPi,代码行数:16,代码来源:x.cpp


示例10: Handler

// ===========================================================================
// method definitions
// ===========================================================================
// ---------------------------------------------------------------------------
// static methods
// ---------------------------------------------------------------------------
void
NIImporter_ITSUMO::loadNetwork(const OptionsCont& oc, NBNetBuilder& nb) {
    // check whether the option is set (properly)
    if (!oc.isSet("itsumo-files")) {
        return;
    }
    /* Parse file(s)
     * Each file is parsed twice: first for nodes, second for edges. */
    std::vector<std::string> files = oc.getStringVector("itsumo-files");
    // load nodes, first
    Handler Handler(nb);
    for (std::vector<std::string>::const_iterator file = files.begin(); file != files.end(); ++file) {
        // nodes
        if (!FileHelpers::exists(*file)) {
            WRITE_ERROR("Could not open itsumo-file '" + *file + "'.");
            return;
        }
        Handler.setFileName(*file);
        PROGRESS_BEGIN_MESSAGE("Parsing nodes from itsumo-file '" + *file + "'");
        if (!XMLSubSys::runParser(Handler, *file)) {
            return;
        }
        PROGRESS_DONE_MESSAGE();
    }
}
开发者ID:rudhir-upretee,项目名称:SUMO_Src,代码行数:31,代码来源:NIImporter_ITSUMO.cpp


示例11: strlen

template<> bool Config<const char *>::Set(const char *newval)
{ 
  if( m_current == newval )
    return true;
  if( m_current && newval && 0==strcmp(newval, m_current) )
    return true;

  if( !Locked() && Valid(newval) ){
    size_t len;
    char *tmp;
    if( m_current ){
      delete []m_current;
      m_current = (const char *)0;
    }
    if( newval ){
      len = strlen(newval);
      if( MaxLen() && len > MaxLen() ) len = MaxLen();
      if( !(tmp = new char[len + 1]) ) return false;
      strncpy(tmp, newval, len);
      tmp[len] = '\0';
      m_current = tmp;
    }
    Handler();
    if(*cfg_verbose)
      CONSOLE.Debug("Config: %s = \"%s\"", Tag(), m_current ? m_current : "");
    return true;
  }
  return false;
}
开发者ID:timpalpant,项目名称:dtorrent,代码行数:29,代码来源:btconfig.cpp


示例12: Handler

void UdpSocket::SetMulticastDefaultInterface(in6_addr a, int if_index)
{
	if (setsockopt(GetSocket(), IPPROTO_IPV6, IPV6_MULTICAST_IF, &if_index, sizeof(if_index)) == -1)
	{
		Handler().LogError(this, "SetMulticastDefaultInterface(ipv6)", Errno, StrError(Errno), LOG_LEVEL_WARNING);
	}
}
开发者ID:f059074251,项目名称:interested,代码行数:7,代码来源:UdpSocket.cpp


示例13: CreateConnection

void UdpSocket::SetMulticastHops(int hops)
{
	if (GetSocket() == INVALID_SOCKET)
	{
		CreateConnection();
	}
	if (!IsIpv6())
	{
		Handler().LogError(this, "SetMulticastHops", 0, "Ipv6 only", LOG_LEVEL_ERROR);
		return;
	}
	if (setsockopt(GetSocket(), IPPROTO_IPV6, IPV6_MULTICAST_HOPS, (char *)&hops, sizeof(int)) == -1)
	{
		Handler().LogError(this, "SetMulticastHops", Errno, StrError(Errno), LOG_LEVEL_WARNING);
	}
}
开发者ID:f059074251,项目名称:interested,代码行数:16,代码来源:UdpSocket.cpp


示例14: Attach

int UdpSocket::Bind(SocketAddress& ad, int range)
{
	if (GetSocket() == INVALID_SOCKET)
	{
		Attach(CreateSocket(ad.GetFamily(), SOCK_DGRAM, "udp"));
	}
	if (GetSocket() != INVALID_SOCKET)
	{
		SetNonblocking(true);
		int n = bind(GetSocket(), ad, ad);
		int tries = range;
		while (n == -1 && tries--)
		{
			ad.SetPort(ad.GetPort() + 1);
			n = bind(GetSocket(), ad, ad);
		}
		if (n == -1)
		{
			Handler().LogError(this, "bind", Errno, StrError(Errno), LOG_LEVEL_FATAL);
			SetCloseAndDelete();
#ifdef ENABLE_EXCEPTIONS
			throw Exception("bind() failed for UdpSocket, port:range: " + Utility::l2string(ad.GetPort()) + ":" + Utility::l2string(range));
#endif
			return -1;
		}
		m_bind_ok = true;
		m_port = ad.GetPort();
		return 0;
	}
	return -1;
}
开发者ID:f059074251,项目名称:interested,代码行数:31,代码来源:UdpSocket.cpp


示例15: fwrite

void HttpClientSocket::OnData(const char *buf,size_t len)
{
	if (m_fil)
	{
		m_fil -> fwrite(buf, 1, len);
	}
	else
	if (m_data_ptr)
	{
		if (m_content_ptr + len > m_data_size)
		{
			Handler().LogError(this, "OnData", -1, "content buffer overflow", LOG_LEVEL_ERROR);
		}
		else
		{
			memcpy(m_data_ptr + m_content_ptr, buf, len);
		}
	}
	m_content_ptr += len;
	if (m_content_ptr == m_content_length && m_content_length)
	{
		if (m_fil)
		{
			m_fil -> fclose();
			delete m_fil;
			m_fil = NULL;
		}
		m_b_complete = true;
		OnContent();
		if (m_b_close_when_complete)
		{
			SetCloseAndDelete();
		}
	}
}
开发者ID:SnowfallIndustries,项目名称:Reality,代码行数:35,代码来源:HttpClientSocket.cpp


示例16: Handler

HRESULT CTryData4Dlg::OnDataXiuzheng(IHTMLElement *pElement)
{
	if(m_State == RUNNING) return S_OK;
	if(m_bAddData)		InternalRoutines('9'); //update the 测量结果
	Handler("compensate",m_sDataSel,m_sDataLst);
	return S_OK;
}
开发者ID:Biotron,项目名称:kpgweigher,代码行数:7,代码来源:TryData4Dlg.cpp


示例17: Send

void StatusSocket::OnAccept()
{
	Send("Local hostname : " + Utility::GetLocalHostname() + "\n");
	Send("Local address : " + Utility::GetLocalAddress() + "\n");
	Send("Number of sockets in list : " + Utility::l2string(Handler().GetCount()) + "\n");
	Send("\n");
}
开发者ID:andhikanugraha,项目名称:tetembakan,代码行数:7,代码来源:StatusSocket.cpp


示例18: OnSocks4ConnectFailed

void SctpSocket::OnException()
{
	if (Connecting())
	{
#ifdef ENABLE_SOCKS4
		if (Socks4())
			OnSocks4ConnectFailed();
		else
#endif
		if (GetConnectionRetry() == -1 ||
			(GetConnectionRetry() &&
			 GetConnectionRetries() < GetConnectionRetry() ))
		{
			// even though the connection failed at once, only retry after
			// the connection timeout
			// should we even try to connect again, when CheckConnect returns
			// false it's because of a connection error - not a timeout...
		}
		else
		{
			SetConnecting(false); // tnx snibbe
			SetCloseAndDelete();
			OnConnectFailed();
		}
		return;
	}
	// %! exception doesn't always mean something bad happened, this code should be reworked
	// errno valid here?
	int err = SoError();
	Handler().LogError(this, "exception on select", err, StrError(err), LOG_LEVEL_FATAL);
	SetCloseAndDelete();
}
开发者ID:BornHunter,项目名称:CGSF,代码行数:32,代码来源:SctpSocket.cpp


示例19: DEFINE_ACTION_FUNCTION

DEFINE_ACTION_FUNCTION(DMessageBoxMenu, CallHandler)
{
	PARAM_PROLOGUE;
	PARAM_POINTERTYPE(Handler, hfunc);
	Handler();
	return 0;
}
开发者ID:ArcticPheenix,项目名称:gzdoom,代码行数:7,代码来源:messagebox.cpp


示例20: pa

void HTTPSocket::url_this(const std::string& url_in,std::string& protocol,std::string& host,port_t& port,std::string& url,std::string& file)
{
	Parse pa(url_in,"/");
	protocol = pa.getword(); // http
	if (!strcasecmp(protocol.c_str(), "https:"))
	{
#ifdef HAVE_OPENSSL
		EnableSSL();
#else
		Handler().LogError(this, "url_this", -1, "SSL not available", LOG_LEVEL_WARNING);
#endif
		port = 443;
	}
	else
	{
		port = 80;
	}
	host = pa.getword();
	if (strstr(host.c_str(),":"))
	{
		Parse pa(host,":");
		pa.getword(host);
		port = static_cast<port_t>(pa.getvalue());
	}
	url = "/" + pa.getrest();
	{
		Parse pa(url,"/");
		std::string tmp = pa.getword();
		while (tmp.size())
		{
			file = tmp;
			tmp = pa.getword();
		}
	}
} // url_this
开发者ID:crashatom,项目名称:phoebemail,代码行数:35,代码来源:HTTPSocket.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ HasAnyFlags函数代码示例发布时间:2022-05-30
下一篇:
C++ Handle_val函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap