本文整理汇总了C++中ERR_EXIT函数的典型用法代码示例。如果您正苦于以下问题:C++ ERR_EXIT函数的具体用法?C++ ERR_EXIT怎么用?C++ ERR_EXIT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ERR_EXIT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 ;
}
示例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);
}
示例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");
}
}
示例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;
}
示例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;
}
示例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));
}
示例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;
}
示例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;
}
示例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
}
示例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);
}
示例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;
}
示例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");
}
示例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;
}
示例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];
}
示例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;
}