MCPcopy Create free account
hub / github.com/F-Stack/f-stack / main

Function main

adapter/syscall/main_stack_epoll_kernel.c:145–260  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

143}
144
145int main(int argc, char * argv[])
146{
147 int i, worker_num = 1;
148
149 signal(SIGINT, sig_term);
150 signal(SIGTERM, sig_term);
151
152 sockfd = socket(AF_INET, SOCK_STREAM, 0);
153 printf("sockfd:%d\n", sockfd);
154 if (sockfd < 0) {
155 printf("ff_socket failed\n");
156 return -1;
157 }
158
159 int on = 1;
160 ioctl(sockfd, FIONBIO, &on);
161
162 struct sockaddr_in my_addr;
163 bzero(&my_addr, sizeof(my_addr));
164 my_addr.sin_family = AF_INET;
165 my_addr.sin_port = htons(80);
166 my_addr.sin_addr.s_addr = htonl(INADDR_ANY);
167
168 int ret = bind(sockfd, (const struct sockaddr *)&my_addr, sizeof(my_addr));
169 if (ret < 0) {
170 printf("ff_bind failed\n");
171 close(sockfd);
172 return -1;
173 }
174
175 ret = listen(sockfd, MAX_EVENTS);
176 if (ret < 0) {
177 printf("ff_listen failed\n");
178 close(sockfd);
179 return -1;
180 }
181
182 sockfd_kernel = socket(AF_INET, SOCK_STREAM | SOCK_KERNEL, 0);
183 printf("sockfd_kernel:%d\n", sockfd_kernel);
184 if (sockfd_kernel < 0) {
185 printf("ff_socket failed\n");
186 return -1;
187 }
188
189 bzero(&my_addr, sizeof(my_addr));
190 my_addr.sin_family = AF_INET;
191 my_addr.sin_port = htons(80);
192 my_addr.sin_addr.s_addr = htonl(INADDR_ANY);
193
194 ret = bind(sockfd_kernel, (const struct sockaddr *)&my_addr, sizeof(my_addr));
195 if (ret < 0) {
196 printf("ff_bind failed\n");
197 close(sockfd);
198 close(sockfd_kernel);
199 return -1;
200 }
201
202 ret = listen(sockfd_kernel, MAX_EVENTS);

Callers

nothing calls this directly

Calls 10

bzeroFunction · 0.85
epoll_createFunction · 0.85
epoll_ctlFunction · 0.85
socketFunction · 0.50
printfFunction · 0.50
ioctlFunction · 0.50
bindFunction · 0.50
closeFunction · 0.50
listenFunction · 0.50
pthread_createFunction · 0.50

Tested by

no test coverage detected