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

C++ ERR_EXIT函数代码示例

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

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



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

示例1: urg_handler

void urg_handler(int signo) {
	int n;
	char c;
	if ( (n = recv(server_fd, &c, 1, MSG_OOB)) < 0) {
		if (errno != EWOULDBLOCK) ERR_EXIT("recv error");
	}
	printf("receive heart beat packet from server\n");
	nprobes = 0;
	return ;
}
开发者ID:lidongmeng,项目名称:UNP,代码行数:10,代码来源:keepAliveClient.cpp


示例2: ERR_EXIT

InetAddress InetAddress::getLocalAddress(int sockfd)
{
    struct sockaddr_in addr;
    socklen_t len = sizeof addr;
    if(::getsockname(sockfd, (SA*)&addr, &len) == -1)
    {
        ERR_EXIT("getsockname");
    }
    return InetAddress(addr);
}
开发者ID:lvchao0428,项目名称:ultrapp,代码行数:10,代码来源:InetAddress.cpp


示例3: activate_oobinline

// 开启套接字fd接收带外数据的功能
void activate_oobinline(int fd)
{
	int oob_inline = 1;
	int ret;
	ret = setsockopt(fd, SOL_SOCKET, SO_OOBINLINE, &oob_inline, sizeof(oob_inline));
	if (ret == -1)
	{
		ERR_EXIT("setsockopt");
	}
}
开发者ID:Tachone,项目名称:Tachftp,代码行数:11,代码来源:sysutil.c


示例4: main

int main(int argc, const char *argv[])
{
    int fd = open("3.txt", O_WRONLY | O_CREAT | O_EXCL, 0666);
    if(fd == -1)
        ERR_EXIT("open");
    char buf[1024] = "wang si ke shi yi ge hao gu niang.";
    write(fd, buf, sizeof(buf));
    close(fd);
    return 0;
}
开发者ID:ShiboBrady,项目名称:cpp,代码行数:10,代码来源:open4.c


示例5: main

int main(int argc, const char *argv[])
{
    int peerfd = socket(PF_INET, SOCK_STREAM, 0);
    if(peerfd == -1)
        ERR_EXIT("socket");

    struct sockaddr_in peeraddr;
    peeraddr.sin_family = AF_INET;
    peeraddr.sin_port = htons(8080);
    peeraddr.sin_addr.s_addr = inet_addr("127.0.0.1");

    if((connect(peerfd, (struct sockaddr*)&peeraddr, sizeof peeraddr)) < 0)
        ERR_EXIT("connect");

    do_service(peerfd);

    close(peerfd);
    return 0;
}
开发者ID:dasima,项目名称:WD,代码行数:19,代码来源:client.c


示例6: myftw

/* 
 * ===  FUNCTION  ======================================================================
 *         Name:  myftw
 *  Description:  
 * =====================================================================================
 */
static int myftw(char *pathname,Myfunc *func){
    fullpath = malloc(sizeof(char)*pathlen);
    if(pathlen <= strlen(pathname)){
        pathlen = strlen(pathname) * 2;
        if((fullpath = realloc(fullpath,pathlen))==NULL)
            ERR_EXIT("relloc failed");
    }
    strcpy(fullpath,pathname);
    return(dopath(func));
}
开发者ID:jasonwust,项目名称:unix,代码行数:16,代码来源:4_22.c


示例7: main

int main(int argc, const char *argv[])
{
    if(signal(SIGPIPE, SIG_IGN) == SIG_ERR)
        ERR_EXIT("signal");
    int fd_server;
    preprocess(&fd_server);
    do_epoll(fd_server); 
    close(fd_server);
    return 0;
}
开发者ID:ShiboBrady,项目名称:cpp,代码行数:10,代码来源:server.c


示例8: TcpClient

int TcpClient(const char* host, uint64_t port)//return peerfd
{
	int peerfd = socket(PF_INET, SOCK_STREAM, 0);		
	if(peerfd == -1)
		ERR_EXIT("socket");	
	
	if(port == 0)//if port=0 then no need to bind
		return peerfd;
	SetAddReuse(peerfd, 1);//add reuse

	SAI addr;	
	memset(&addr, 0, sizeof addr);	
	addr.sin_family = AF_INET; 
	addr.sin_port = htons(port);
	addr.sin_addr.s_addr = inet_addr(host);
	if(bind(peerfd, (SA*)&addr, sizeof addr) == -1)
		ERR_EXIT("bind client");
	return peerfd;
}
开发者ID:presentzeng,项目名称:2014,代码行数:19,代码来源:tcp.c


示例9: SetPortReuse

void SetPortReuse(int sockfd, int optval)//port reuse
{
#ifdef SO_REUSEPORT
    int on = (optval != 0) ? 1 : 0;
    if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEPORT, &on, sizeof(on)) < 0)
        ERR_EXIT("setsockopt SO_REUSEPORT");
#else
    fprintf(stderr, "SO_REUSEPORT is not supported.\n");
#endif //SO_REUSEPORT
}
开发者ID:presentzeng,项目名称:2014,代码行数:10,代码来源:tcp.c


示例10: dt_init

/*
 * Init dump tool backends
 */
void dt_init(void)
{
	struct dt *dt;
	int i = 0;

	while ((dt = dt_vec[i])) {
		g.fh = zg_open(g.opts.device, O_RDONLY, ZG_CHECK);
		if (!S_ISBLK(g.fh->sb.st_mode))
			ERR_EXIT("Please specify DASD or SCSI device node"
				 "(e.g. /dev/dasdd or /dev/sda )");
		if (dt->init() == 0) {
			l.dt = dt;
			return;
		}
		zg_close(g.fh);
		i++;
	}
	ERR_EXIT("No dump tool found on \"%s\"", g.opts.device);
}
开发者ID:hreinecke,项目名称:s390-tools,代码行数:22,代码来源:dt.c


示例11: main

int main(int argc, char *argv[])
{
	int msgid;
	msgid = msgget(1234, 0);
	if (msgid == -1)
		ERR_EXIT("msgget");

	echo_cli(msgid);
	return 0;
}
开发者ID:hzsunzixiang,项目名称:programming,代码行数:10,代码来源:echocli.c


示例12: set_minprivilage

void set_minprivilage(void)
{
    struct passwd* pwd = getpwnam("nobody");
    if ( NULL == pwd )
        ERR_EXIT("getpwnam error");
    if ( -1 == setegid(pwd->pw_gid))
        ERR_EXIT("setegid error"); 
    if ( -1 == seteuid(pwd->pw_uid))
        ERR_EXIT("seteuid error"); 

    struct __user_cap_header_struct cap_header;
    cap_header.version = _LINUX_CAPABILITY_VERSION_1;
    cap_header.pid = 0;
    struct __user_cap_data_struct cap_data;
    cap_data.effective = cap_data.permitted = 1 << CAP_NET_BIND_SERVICE;
    cap_data.inheritable = 0;
    if ( -1 == capset(&cap_header,&cap_data))
        ERR_EXIT("capset error");
}
开发者ID:icysunlight,项目名称:miniftpd,代码行数:19,代码来源:ftpnobody.c


示例13: main

int main(int argc, const char *argv[])
{
    int iret;
    if(argc == 1){
        ERR_EXIT("too few args");
    }else{
        iret = mkdir(argv[1], 0777);
    }
    return 0;
}
开发者ID:chenfan2014,项目名称:CFgit,代码行数:10,代码来源:my_mkdir.c


示例14: priv_sock_init

void priv_sock_init(session_t *sess)
{
    int fds[2];
    /* 创建一对UNIX域的套接字,用于进程间通信 */
    if(socketpair(PF_UNIX, SOCK_STREAM, 0, fds) == -1)
        ERR_EXIT("socketpair");

    sess->nobody_fd = fds[0];
    sess->proto_fd = fds[1];
}
开发者ID:chenhanzhun,项目名称:NetWorkProgramming,代码行数:10,代码来源:priv_sock.c


示例15: main

int main(int argc, const char *argv[])
{
    int fd = open("test.txt", O_RDONLY, 0666);
    if(fd == -1)
        ERR_EXIT("open");

    char buf[1024] = {0};
    int ret = read(fd, buf, 5);
    if(ret == -1)
        ERR_EXIT("read");
    printf("buf ---- %s\n", buf);

    off_t len = lseek(fd, 0, SEEK_CUR);
    printf("len ---- %d\n", (int)len);

    len = lseek(fd, 5, SEEK_CUR);
    printf("len ---- %d\n", (int)len);
    return 0;
}
开发者ID:dasima,项目名称:WD,代码行数:19,代码来源:hole1.c


示例16: main

int main(int argc, char* argv[])
{
    int peerfd = socket(AF_INET, SOCK_STREAM, 0);
    if(peerfd == -1)
    {
        ERR_EXIT("socket");
    }
    struct sockaddr_in client_addr;
    memset(client_addr, 0, sizeo(client_addr));
    client_addr.sin_family = AF_INET;
    client_addr.sin_addr.s_addr = inet_addr("192.168.175.128");
    client_addr.sin_port = htons(9999);
    socklen_t sock_len = sizeof(client_addr);
    if(-1 == connect(sockdf, (struct sockaddr&)*client_addr, sock_len))
    {
        ERR_EXIT("connect");
    }
    do_service(peerfd);
}
开发者ID:Fransunshine,项目名称:chapters_wd_git,代码行数:19,代码来源:client.cpp


示例17: sem_setval

int sem_setval(int semid, int val)
{
	union semun su;
	su.val = val;
	int ret;
	ret = semctl(semid, 0, SETVAL, su);
	if(ret == -1)
	  ERR_EXIT("semctl");
	return 0;
}
开发者ID:SnailGeek,项目名称:LearningSocketProgram,代码行数:10,代码来源:sem.c


示例18: main

int main() {
    int listen_fd;
    // create a socket for listening
    if ((listen_fd = socket(PF_UNIX, SOCK_STREAM, 0)) < 0) {
        ERR_EXIT("socket function return negative");
    }
    unlink(SOCKET_FILE);
    struct sockaddr_un server_addr;
    memset(&server_addr, 0, sizeof(server_addr));
    server_addr.sun_family = AF_UNIX;
    strcpy(server_addr.sun_path, SOCKET_FILE);
    // bind a address to the listening socket for clients to connect
    if (bind(listen_fd, (struct sockaddr*) &server_addr, sizeof(server_addr)) < 0) {
        ERR_EXIT("bind error");
    }
    // start to listen for connecting request
    if (listen(listen_fd, SOMAXCONN) < 0) {
        ERR_EXIT("listen error");
    }

    while (1) {
        // create a new socket, which implies a new connection between server and client
        int conn_fd = accept(listen_fd, NULL, NULL);
        if (conn_fd == -1) {
            if (conn_fd == EINTR) continue;
            ERR_EXIT("acccept error");
        }

        pid_t pid = fork();
        if (pid == -1) {
            ERR_EXIT("fork error");
        }
        if (pid == 0) {
            close(listen_fd);
            echo_server(conn_fd);
            exit(EXIT_SUCCESS);
        }

        close(conn_fd);
    }

    return 0;
}
开发者ID:xiongjp,项目名称:note,代码行数:43,代码来源:echo_server.c


示例19: main

int main(void)
{
	int sock;
	if ((sock = socket(PF_INET, SOCK_DGRAM, 0)) < 0)
		ERR_EXIT("socket");

	echo_cli(sock);

	return 0;
}
开发者ID:JnuSimba,项目名称:UNP,代码行数:10,代码来源:echocli_udp.c


示例20: get_time_sec

long get_time_sec()
{
	int ret = gettimeofday(&s_curr_time, NULL);
	if (ret < 0)
	{
		ERR_EXIT("gettimeofday");
	}
	return s_curr_time.tv_sec;
	
}
开发者ID:DiaosiDev,项目名称:Tinyftp,代码行数:10,代码来源:sckutil.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ ERR_FAIL函数代码示例发布时间:2022-05-30
下一篇:
C++ ERROR_message函数代码示例发布时间: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