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


C++ pj_get_native_netos_error函数代码示例

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


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

示例1: PJ_DEF

/*
 * Create new socket/endpoint for communication and returns a descriptor.
 */
PJ_DEF(pj_status_t) pj_sock_socket(int af, 
				   int type, 
				   int proto, 
				   pj_sock_t *sock)
{

    PJ_CHECK_STACK();

    /* Sanity checks. */
    PJ_ASSERT_RETURN(sock!=NULL, PJ_EINVAL);
    PJ_ASSERT_RETURN(PJ_INVALID_SOCKET==-1, 
                     (*sock=PJ_INVALID_SOCKET, PJ_EINVAL));
    
    *sock = socket(af, type, proto);
    if (*sock == PJ_INVALID_SOCKET)
	return PJ_RETURN_OS_ERROR(pj_get_native_netos_error());
    else {
	pj_int32_t val = 1;
	if (type == pj_SOCK_STREAM()) {
	    pj_sock_setsockopt(*sock, pj_SOL_SOCKET(), pj_SO_NOSIGPIPE(),
			       &val, sizeof(val));
	}
#if defined(PJ_IPHONE_OS_HAS_MULTITASKING_SUPPORT) && \
    PJ_IPHONE_OS_HAS_MULTITASKING_SUPPORT!=0
	if (type == pj_SOCK_DGRAM()) {
	    pj_sock_setsockopt(*sock, pj_SOL_SOCKET(), SO_NOSIGPIPE, 
			       &val, sizeof(val));
	}
#endif
	return PJ_SUCCESS;
    }
}
开发者ID:chiefdome,项目名称:asterisk,代码行数:35,代码来源:sock_bsd.c

示例2: PJ_DEF

/*
 * Create new socket/endpoint for communication and returns a descriptor.
 */
PJ_DEF(pj_status_t) pj_sock_socket(int af, 
				   int type, 
				   int proto, 
				   pj_sock_t *sock)
{

    PJ_CHECK_STACK();

    /* Sanity checks. */
    PJ_ASSERT_RETURN(sock!=NULL, PJ_EINVAL);
    PJ_ASSERT_RETURN(PJ_INVALID_SOCKET==-1, 
                     (*sock=PJ_INVALID_SOCKET, PJ_EINVAL));

    *sock = socket(af, type, proto);
    if (*sock == PJ_INVALID_SOCKET)
	return PJ_RETURN_OS_ERROR(pj_get_native_netos_error());
    else 
	return PJ_SUCCESS;
}
开发者ID:vinc6nt,项目名称:p2pnt,代码行数:22,代码来源:sock_bsd.c

示例3: PJ_DEF

/*
 * Bind socket.
 */
PJ_DEF(pj_status_t) pj_sock_bind( pj_sock_t sock,
				  const pj_sockaddr_t *addr,
				  int len)
{
    PJ_CHECK_STACK();

    PJ_ASSERT_RETURN(addr && len >= (int)sizeof(struct sockaddr_in), PJ_EINVAL);

    CHECK_ADDR_LEN(addr, len);

    pj_int32_t val = 1;
    int rc = pj_sock_setsockopt(sock, pj_SOL_SOCKET(), pj_SO_REUSEADDR(), &val, sizeof(val));
    if (rc != 0)
        return rc;

    if (bind(sock, (struct sockaddr*)addr, len) != 0)
	return PJ_RETURN_OS_ERROR(pj_get_native_netos_error());
    else
	return PJ_SUCCESS;
}
开发者ID:oldurecu,项目名称:pjsip-upstream,代码行数:23,代码来源:sock_bsd.c

示例4: PJ_DEF

/*
 * Send data
 */
PJ_DEF(pj_status_t) pj_sock_send(pj_sock_t sock,
				 const void *buf,
				 pj_ssize_t *len,
				 unsigned flags)
{
    PJ_CHECK_STACK();
    PJ_ASSERT_RETURN(len, PJ_EINVAL);

#ifdef MSG_NOSIGNAL
    /* Suppress SIGPIPE. See https://trac.pjsip.org/repos/ticket/1538 */
    flags |= MSG_NOSIGNAL;
#endif

    *len = send(sock, (const char*)buf, *len, flags);

    if (*len < 0)
	return PJ_RETURN_OS_ERROR(pj_get_native_netos_error());
    else
	return PJ_SUCCESS;
}
开发者ID:CryptoCall,项目名称:pjsip,代码行数:23,代码来源:sock_bsd.c

示例5: PJ_DEF

/*
 * Set socket option.
 */
PJ_DEF(pj_status_t) pj_sock_setsockopt( pj_sock_t sock,
					pj_uint16_t level,
					pj_uint16_t optname,
					const void *optval,
					int optlen)
{
    int status;
    PJ_CHECK_STACK();
    
#if (defined(PJ_WIN32) && PJ_WIN32) || (defined(PJ_SUNOS) && PJ_SUNOS)
    /* Some opt may still need int value (e.g:SO_EXCLUSIVEADDRUSE in win32). */
    status = setsockopt(sock, 
		     level, 
		     ((optname&0xff00)==0xff00)?(int)optname|0xffff0000:optname, 		     
		     (const char*)optval, optlen);
#else
    status = setsockopt(sock, level, optname, (const char*)optval, optlen);
#endif

    if (status != 0)
	return PJ_RETURN_OS_ERROR(pj_get_native_netos_error());
    else
	return PJ_SUCCESS;
}
开发者ID:CloudStyleStudio,项目名称:csip,代码行数:27,代码来源:sock_bsd.c

示例6: PJ_DEF

/*
* Create new socket/endpoint for communication and returns a descriptor.
*/
PJ_DEF(pj_status_t) pj_sock_socket(int af, 
																	 int type, 
																	 int proto,
																	 pj_sock_t *sock)
{
	PJ_CHECK_STACK();

	/* Sanity checks. */
	PJ_ASSERT_RETURN(sock!=NULL, PJ_EINVAL);
	PJ_ASSERT_RETURN((unsigned)PJ_INVALID_SOCKET==INVALID_SOCKET, 
		(*sock=PJ_INVALID_SOCKET, PJ_EINVAL));

	*sock = WSASocket(af, type, proto, NULL, 0, WSA_FLAG_OVERLAPPED);

	if (*sock == PJ_INVALID_SOCKET) 
		return PJ_RETURN_OS_ERROR(pj_get_native_netos_error());

#if PJ_SOCK_DISABLE_WSAECONNRESET && \
	(!defined(PJ_WIN32_WINCE) || PJ_WIN32_WINCE==0)

#ifndef SIO_UDP_CONNRESET
#define SIO_UDP_CONNRESET _WSAIOW(IOC_VENDOR,12)
#endif

	/* Disable WSAECONNRESET for UDP.
	* See https://trac.pjsip.org/repos/ticket/1197
	*/
	if (type==PJ_SOCK_DGRAM) {
		DWORD dwBytesReturned = 0;
		BOOL bNewBehavior = FALSE;
		DWORD rc;


		int iOptVal;
		int retOpt;
		int iOptLen;
		int iOptValRet = 0;
		iOptLen = sizeof(int);
		// POPOV: for debug
		//retOpt = getsockopt(*sock, SOL_SOCKET, SO_SNDBUF, (char*)&iOptValRet, &iOptLen);
		//retOpt = getsockopt(*sock, SOL_SOCKET, SO_RCVBUF, (char*)&iOptValRet, &iOptLen);

		// POPOV: setting socket buffers
		//iOptVal = 2097152;
		iOptVal = 65536;
		retOpt = setsockopt(*sock, SOL_SOCKET, PJ_SO_SNDBUF, (char*)&iOptVal, iOptLen);
		retOpt = setsockopt(*sock, SOL_SOCKET, PJ_SO_RCVBUF, (char*)&iOptVal, iOptLen);


		// POPOV: for debug
		//retOpt = getsockopt(*sock, SOL_SOCKET, SO_SNDBUF, (char*)&iOptValRet, &iOptLen);
		//retOpt = getsockopt(*sock, SOL_SOCKET, SO_RCVBUF, (char*)&iOptValRet, &iOptLen);
		 

		rc = WSAIoctl(*sock, SIO_UDP_CONNRESET,
			&bNewBehavior, sizeof(bNewBehavior),
			NULL, 0, &dwBytesReturned,
			NULL, NULL);
		


		if (rc==SOCKET_ERROR) {
			// Ignored..
		}
	}
#endif

	return PJ_SUCCESS;
}
开发者ID:silvansky,项目名称:pjsip_mod,代码行数:72,代码来源:sock_bsd.c


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