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


C++ UsageEnvironment::getErrno方法代码示例

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


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

示例1: readSocket

int readSocket(UsageEnvironment& env,
				 int socket, unsigned char* buffer, unsigned bufferSize,
				 struct sockaddr_in& fromAddress,
				 struct timeval* timeout) {
  int bytesRead = -1;
  do {
	  int result = blockUntilReadable(env, socket, timeout);
	  if (timeout != NULL && result == 0) {
		  bytesRead = 0;
		  break;
		} else if (result <= 0) {
		  break;
		}

	  SOCKLEN_T addressSize = sizeof fromAddress;
	  bytesRead = recvfrom(socket, (char*)buffer, bufferSize, 0,
			 (struct sockaddr*)&fromAddress,
			 &addressSize);
	  if (bytesRead < 0) {
			//##### HACK to work around bugs in Linux and Windows:
		  int err = env.getErrno();
		  if (err == 111 /*ECONNREFUSED (Linux)*/
#if defined(__WIN32__) || defined(_WIN32)
		// What a piece of crap Windows is.  Sometimes
		// recvfrom() returns -1, but with an 'errno' of 0.
		// This appears not to be a real error; just treat
		// it as if it were a read of zero bytes, and hope
		// we don't have to do anything else to 'reset'
		// this alleged error:
		|| err == 0
#else
		|| err == EAGAIN
#endif
		|| err == 113 /*EHOSTUNREACH (Linux)*/) {
							//Why does Linux return this for datagram sock?
	fromAddress.sin_addr.s_addr = 0;
	return 0;
			}
			//##### END HACK
		  socketErr(env, "recvfrom() error: ");
		  break;
		}
	} while (0);

  return bytesRead;
}
开发者ID:JammyWei,项目名称:ver30,代码行数:46,代码来源:GroupsockHelper.cpp

示例2: socketJoinGroup

Boolean socketJoinGroup(UsageEnvironment& env, int socket,
			netAddressBits groupAddress){
  if (!IsMulticastAddress(groupAddress)) return True; // ignore this case

  struct ip_mreq imr;
  imr.imr_multiaddr.s_addr = groupAddress;
  imr.imr_interface.s_addr = ReceivingInterfaceAddr;
  if (setsockopt(socket, IPPROTO_IP, IP_ADD_MEMBERSHIP,
		 (const char*)&imr, sizeof (struct ip_mreq)) < 0) {
#if defined(__WIN32__) || defined(_WIN32)
	  if (env.getErrno() != 0) {
			// That piece-of-shit toy operating system (Windows) sometimes lies
			// about setsockopt() failing!
#endif
		  socketErr(env, "setsockopt(IP_ADD_MEMBERSHIP) error: ");
		  return False;
#if defined(__WIN32__) || defined(_WIN32)
		}
#endif
	}

  return True;
}
开发者ID:ShawnOfMisfit,项目名称:ambarella,代码行数:23,代码来源:GroupsockHelper.cpp

示例3: printErr

static void printErr(UsageEnvironment& env, char const* str = NULL) {
  if (str != NULL) err(env) << str;
  env << ": " << strerror(env.getErrno()) << "\n";
}
开发者ID:epheatt,项目名称:wis-streamer,代码行数:4,代码来源:WISInput.cpp


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