LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-15-2014, 07:20 AM   #1
chenjintao_ii
LQ Newbie
 
Registered: Dec 2011
Posts: 27

Rep: Reputation: Disabled
how to scan LAN with epoll()?


followed is my code:

epfd = epoll_create(255*255);
for (ip = 192.168.1.1; ip <= 192.168.255.255; ip++) {
fd = socket();
ev.event = EPOLLOUT|EPOLLIN;
ev.data.fd = fd;
epoll_ctl(epfd, EPOLL_CTL_ADD, fd, &env);
}

while (1) {
epoll_wait(epfd, evlist, 255*255, 1000);
...
}


But i think this is the most stupid solution. So any one can give a better one?

thanks in advance & best regards
 
Old 10-16-2014, 11:24 PM   #2
gdejonge
Member
 
Registered: Aug 2010
Location: Netherlands
Distribution: Kubuntu, Debian, Suse, Slackware
Posts: 317

Rep: Reputation: 73
Hi,

First. I would expect that if you try to compile that piece of code, your compiler would throw several errors.

But here is a link how to use epoll() how-to-use-epoll-a-complete-example-in-c

Second. Try to restate the problem you try to solve. I'm not sure if I understand your question correctly.

Cheers.
 
Old 10-21-2014, 06:53 AM   #3
chenjintao_ii
LQ Newbie
 
Registered: Dec 2011
Posts: 27

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by gdejonge View Post
Hi,

First. I would expect that if you try to compile that piece of code, your compiler would throw several errors.

But here is a link how to use epoll() how-to-use-epoll-a-complete-example-in-c

Second. Try to restate the problem you try to solve. I'm not sure if I understand your question correctly.

Cheers.
Thank you for your reply.
I've read your link but it can not resolve my problem, because it just create one connect request.
I want to find out which host can respond my connect request in one LAN, so I need connect all hosts in the LAN, then wait for their reply. The most important thing is that I must assume the count of hosts in one LAN is 255 or 255*255, even 255*255*255,and if I connect one by one in a thread, there must be more than 255*255(*255) socket file descriptors at one time. So I think this solution is stupid.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Asynchronous I/O and epoll sols2008 Linux - Networking 1 06-28-2011 10:08 PM
public ip scanned by nmap during private lan scan goober3 Linux - Security 2 09-14-2008 02:45 PM
epoll jopu Linux - Networking 0 11-05-2007 11:27 PM
epoll problem Parahat Melayev Programming 1 03-17-2005 05:22 AM


All times are GMT -5. The time now is 10:22 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration