Example: exit when ff_api failed

dev
logwang 2017-09-14 18:57:37 +08:00
parent 8cf1d457cb
commit 1a527102bc
3 changed files with 16 additions and 7 deletions

View File

@ -4,6 +4,7 @@
![](F-Stack.png)
## Introduction
With the rapid development of NIC, the poor performance of data packets processing with Linux kernel has become the bottleneck. However, the rapid development of the Internet needs high performance of network processing, kernel bypass has caught more and more attentions. There are various similar technologies appear, such as DPDK, NETMAP and PF_RING. The main idea of kernel bypass is that Linux is only used to deal with control flow, all data streams are processed in user space. Therefore, kernel bypass can avoid performance bottlenecks caused by kernel packet copying, thread scheduling, system calls and interrupts. Furthermore, kernel bypass can achieve higher performance with multi optimizing methods. Within various techniques, DPDK has been widely used because of its more thorough isolation from kernel scheduling and active community support.
[F-Stack](http://www.f-stack.org/?from=github) is an open source network framework with high performance based on DPDK. With following characteristics

View File

@ -107,8 +107,10 @@ int main(int argc, char * argv[])
sockfd = ff_socket(AF_INET, SOCK_STREAM, 0);
printf("sockfd:%d\n", sockfd);
if (sockfd < 0)
if (sockfd < 0) {
printf("ff_socket failed\n");
exit(1);
}
struct sockaddr_in my_addr;
bzero(&my_addr, sizeof(my_addr));
@ -119,11 +121,13 @@ int main(int argc, char * argv[])
int ret = ff_bind(sockfd, (struct linux_sockaddr *)&my_addr, sizeof(my_addr));
if (ret < 0) {
printf("ff_bind failed\n");
exit(1);
}
ret = ff_listen(sockfd, MAX_EVENTS);
if (ret < 0) {
printf("ff_listen failed\n");
exit(1);
}
kevSet.data = MAX_EVENTS;

View File

@ -102,8 +102,10 @@ int main(int argc, char * argv[])
sockfd = ff_socket(AF_INET, SOCK_STREAM, 0);
printf("sockfd:%d\n", sockfd);
if (sockfd < 0)
if (sockfd < 0) {
printf("ff_socket failed\n");
exit(1);
}
int on = 1;
ff_ioctl(sockfd, FIONBIO, &on);
@ -117,11 +119,13 @@ int main(int argc, char * argv[])
int ret = ff_bind(sockfd, (struct linux_sockaddr *)&my_addr, sizeof(my_addr));
if (ret < 0) {
printf("ff_bind failed\n");
exit(1);
}
ret = ff_listen(sockfd, MAX_EVENTS);
if (ret < 0) {
printf("ff_listen failed\n");
exit(1);
}
assert((epfd = ff_epoll_create(0)) > 0);