Synchronous I/O
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > Synchronous I/O




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Synchronous I/O  
seema


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
04-23-07 12:19 PM

Hi all,

I have a problem when I started debugging , select () call always
returns -1. I have made a small sample
that reproduces the problem, can some body indicate what is the
problem here,

#include <sys/time.h>

int main(int argc, char *argv[])
{

fd_set fd_s;
int lsock,ret;
struct timeval timeout;

timeout.tv_sec  = 1;
timeout.tv_usec = 0;

lsock=3;

FD_ZERO(&fd_s);

FD_SET(lsock, &fd_s);

ret=select(lsock+1,(void *)&fd_s, (void *)0, (void *)0,
&timeout);

printf ("%d",ret);
}

select() call always returns -1?

Thanks in advance,
Seema Rao






[ Post a follow-up to this message ]



    Re: Synchronous I/O  
Casper H.S. Dik


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
04-23-07 12:19 PM

seema <seema_coma@yahoo.co.in> writes:

>Hi all,

>I have a problem when I started debugging , select () call always
>returns -1. I have made a small sample
>that reproduces the problem, can some body indicate what is the
>problem here,

>#include <sys/time.h>

>int main(int argc, char *argv[])
>{

>        fd_set fd_s;
>        int lsock,ret;
>        struct timeval timeout;

>        timeout.tv_sec  = 1;
>        timeout.tv_usec = 0;

>        lsock=3;

>        FD_ZERO(&fd_s);

>        FD_SET(lsock, &fd_s);

>        ret=select(lsock+1,(void *)&fd_s, (void *)0, (void *)0,
>&timeout);

>        printf ("%d",ret);
>}

>select() call always returns -1?


errno is probably always EBADF.

File descriptor 3 point to what file?

Casper
--
Expressed in this posting are my opinions.  They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.





[ Post a follow-up to this message ]



    Re: Synchronous I/O  
Bin Chen


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
04-24-07 06:23 PM

On 4=D4=C223=C8=D5, =CF=C2=CE=E76=CA=B138=B7=D6, seema <seema_c...@yahoo.co=
.in> wrote:
> Hi all,
>
> I have a problem when I started debugging , select () call always
> returns -1. I have made a small sample
> that reproduces the problem, can some body indicate what is the
> problem here,
>
> #include <sys/time.h>
>
> int main(int argc, char *argv[])
> {
>
>         fd_set fd_s;
>         int lsock,ret;
>         struct timeval timeout;
>
>         timeout.tv_sec  =3D 1;
>         timeout.tv_usec =3D 0;
>
>         lsock=3D3;

You didn't assign lsock to a return from open() or socket() etc, only
0, 1, 2 is opened by system default, so fd number 3 is incorrect.







[ Post a follow-up to this message ]



    Re: Synchronous I/O  
chsalvia@gmail.com


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
04-25-07 12:18 AM

You need to actually create a socket before you use select().






[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 06:17 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register