This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: select() doesn't respond


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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]