mirror of https://github.com/F-Stack/f-stack.git
Example: exit when ff_api failed
This commit is contained in:
parent
8cf1d457cb
commit
1a527102bc
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue