This is the mail archive of the
cygwin@cygwin.com
mailing list for the Cygwin project.
Re: select() doesn't respond
- From: Brian Dessent <brian at dessent dot net>
- To: cygwin at cygwin dot com
- Date: Wed, 22 Oct 2003 20:29:32 -0700
- Subject: Re: select() doesn't respond
- Organization: My own little world...
- References: <20031023025857.932.qmail@web303.mail.yahoo.co.jp>
Takeshi Honda wrote:
> if ((sock=socket(AF_INET,SOCK_RAW,IPPROTO_TCP))==-1){
> printf("Can not create RAW socket.\n");
> return -1;
> }
>
> FD_ZERO(&read_fd);
> FD_SET(sock,&read_fd);
> select(FD_SETSIZE,&read_fd,NULL,NULL,NULL); // program
> stop here
You create a socket but you don't call bind(), connect(), or listen() on
it so I don't know what you expect to happen. AFAIK just creating a
socket and then trying to read from it is an undefined behavior, but I
could be wrong. If you're trying to read raw packets off the interface
you're going to need to use libpcap. Fortunately, there is a libpcap
library for Windows (called WinPcap), and there are cygwin bindings for
it so it can be used in the same way as with linux. There are a handful
of examples that come with the library code, so you should probably
start there.
Brian
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/