Thread: Numering of file descriptors

  1. #1
    Registered User
    Join Date
    Jun 2003
    Posts
    31

    Numering of file descriptors

    in wich mode windows system assigns id to file descriptors like socket, in unix system the assignment is in ascending order (the first id's socket is 3 the second 4 and so on).
    In windows i saw that the first id's socket is 100, the second 104, the third 108 and so on...

    is it right?

    thank u.

    bye

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    I believe it should be the same. Incremented by one. I just did a brief check and didn't see anything right off. Granted I only spent two seconds with a search engine, but if you give it a few more, you'll likely come up with something.

    One quick reference I noted is the ever popular sockets web site.

    [edit] Curses, foiled again! [/edit]

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered User
    Join Date
    Jun 2003
    Posts
    31
    my problem is this:
    i want to use the select() function to use non blocking sockets,
    when i put a socket(file) descriptor in FD_SET i don't know how to iterate on fd_set to find the ready socket,
    in unix is quite simple because if u close all stream than the socket descriptor is from 0 to FD_SETSIZE(64).

    do u understand?

  4. #4
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Read here or try vVv's Unix FAQ (the principles are the same for Windows socket I believe).
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  5. #5
    Registered User
    Join Date
    Jun 2003
    Posts
    31
    view this unix system program:

    /*
    ** select.c -- a select() demo
    */

    #include <stdio.h>
    #include <sys/time.h>
    #include <sys/types.h>
    #include <unistd.h>

    #define STDIN 0 // file descriptor for standard input

    int main(void)
    {
    struct timeval tv;
    fd_set readfds;

    tv.tv_sec = 2;
    tv.tv_usec = 500000;

    FD_ZERO(&readfds);
    FD_SET(STDIN, &readfds);

    // don't care about writefds and exceptfds:
    select(STDIN+1, &readfds, NULL, NULL, &tv);

    if (FD_ISSET(STDIN, &readfds))
    printf("A key was pressed!\n");
    else
    printf("Timed out.\n");

    return 0;
    }

    see the select function (STDIN+1) in windows i can't dothis because the fd is not in ascending order....

    please help me!

  6. #6
    Registered User
    Join Date
    Jun 2003
    Posts
    31
    for ( i = 0 ; i < FD_SETSIZE ; i++ ) if ( FD_ISSET(i,&set) ) { /* do stuff */ }

    i can't do this because in windows FD_SETSIZE is 64 and if the firs socket descriptor is 100 it never enter in that loop......doh!

  7. #7
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Please don't cross post
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A development process
    By Noir in forum C Programming
    Replies: 37
    Last Post: 07-10-2011, 10:39 PM
  2. Inventory records
    By jsbeckton in forum C Programming
    Replies: 23
    Last Post: 06-28-2007, 04:14 AM
  3. help with text input
    By Alphawaves in forum C Programming
    Replies: 8
    Last Post: 04-08-2007, 04:54 PM
  4. Numering of file descriptors
    By Massive in forum Windows Programming
    Replies: 1
    Last Post: 06-24-2003, 06:50 AM
  5. Need a suggestion on a school project..
    By Screwz Luse in forum C Programming
    Replies: 5
    Last Post: 11-27-2001, 02:58 AM