linux - accept/epoll problem -


I have this code which uses Apollo and its problem is when I run it, it returns output : Server-socket () OK ... Server-Bind () OK ... 3 4 Accept: Invalid argument

I'm running it on Ubuntu Linux, the system is updated What is wrong with the input to accept both as limited user and root? What should I change?

  straight epoll_event ev, event [MAX_EVENTS]; Struct sockaddr_in serveraddr; Int listen_sock, conn_sock, nfds, epollfd; Int Yes = 1; / * (Sonset = Socket (AF_INET, SOCK_STREAM, 0)) == -1) {perror ("server-socket (error is correct!)"); // Just Exit Eligible! Exit (1); } Printf ("Server-socket (OK) ... \ n"); // "address already in use" error message / * if (setocopat (solock, SOO, SOOOKADDR, and yes, size) == -1) {mirror ("server-setcuts (error error)") ; Exit (1); } Printf ("Server-SetupPat () is OK ... \ n"); * / / Bind serveraddr.sin_family = AF_INET; Serveraddr.sin_addr.s_addr = INADDR_ANY; Serveraddr.sin_port = htons (PORT); Memset (& amp; (serveraddr.sin_zero), '\ 0', 8); If (dams (Sunscosk, (Structured Socied *) and ServerAdWords, Size (serverAD)) == -1) {Explanation ("Server-Bind (error) Qualified!"); Exit (1); } Printf ("Server-Bind () OK ... \ n"); ApolloFed = Apoll_CRETE (MAX_EVENTS); If (epollfd == -1) {mirror ("epoll_create"); Exhaust (EXIT_FAILURE); } Ev.events = EPOLLIN; Ev.data.fd = listen_sock; If (Apol_ttl (Apollfed, EPOLLCTL_ADD, ISOLOCOC, and EVU) == -1) {clarification ("Apoll_CTL: ISOOK"); Exhaust (EXIT_FAILURE); } (;;) {nfds = epoll_wait (Apolloids, Events, MAX_EVENTS, -1); If (NFDS == -1) {mirror ("Apol_Pivate"); Exhaust (EXIT_FAILURE); } For (int n = 0; n & lt; nfds; ++ n) {if (events [n] .data.fd == listen_sock) {struct sockaddr_in clientaddr; Socklen_t addrlen = sizeof (clientaddr); Cout & lt; & Lt; Listen_sock & lt; & Lt; '\ N' & lt; & Lt; Epollfd & lt; & Lt; '\ N'; Conn_sock = Accepted (Sunny-Sock, (Structure Sokadar *) and Client Adrutter, and Adrilan); If (conn_sock == -1) {false ("accept"); Exhaust (EXIT_FAILURE); } Fcntl (conn_sock, F_SETFL, fcntl (conn_sock, F_GETFD, 0) | O_NONBLOCK); Ev.events = EPOLLIN | EPOLLET; Ev.data.fd = conn_sock; If (Apoll_ttl (Apollfed, EPOLLTCLL_ADD, CON_Sock, and EVU) == -1) {Spirit ("Apoll_CTL: Con_Sock"); Exhaust (EXIT_FAILURE); }} Other {printf ("% d \ n", events [n] .data.fd); ():   

You forgot to call ():

  Listen (listen_sock, 5);  

Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -