Problems with using pipe(...); on select(...);

This is a discussion on Problems with using pipe(...); on select(...); within the Linux Programming forums, part of the Platform Specific Boards category; Hello all, My problem is as follows: I'm trying to wake up a select(...); using a pipe fd. This should ...

  1. #1
    Registered User
    Join Date
    Jan 2006
    Posts
    2

    Problems with using pipe(...); on select(...);

    Hello all,

    My problem is as follows:

    I'm trying to wake up a select(...); using a pipe fd. This should be rather straightforward, but I cannot get it to work. Perhaps you guys could give me a few tips.

    My wakeup function looks like this:

    Code:
    STATIC void net_trig_wr()
    {
       /* write a dummy to wake up net thread */
       write(net_pipefd, _T("TRIG"), 4);
    }
    This pipe is created using:

    Code:
       int pipe_set[2];
       ALLEGE(pipe(pipe_set) == 0);
       net_pipefd = pipe_set[1];
       FD_SET(pipe_set[0], &net_rd_set);

    And the net_rd_set is the set select uses:

    Code:
     ALLEGE((res = select(maxfd+1, &net_rd_set, &net_wr_set, NULL, NULL)) != -1);
    Of course the maxfd is set to:
    Code:
     maxfd = pipe_set[0];
    It should be noted net_trig_wr(); is called from another thread (created using POSIX-threads) than the select(...) operates in.

    I've attached the entire net.c file (as net.txt) in this document. So if you want to have a look at it to help me further. Feel free to get inspired by my code also (if there is anything to get inspired by).

    Any tips would be usefull!

    / Henrik, Sweden

    (For the intressted, im actually rewriting a Java-server I've done for www.betapet.com which is a free swedish scrabble-site)
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    Jan 2006
    Posts
    2
    I am sorry if I posted this thread in the wrong forum. My apoligizes

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. No clue how to make a code to solve problems!
    By ctnzn in forum C Programming
    Replies: 8
    Last Post: 10-16-2008, 02:59 AM
  2. still problems with ceasar shift
    By trevordunstan in forum C Programming
    Replies: 2
    Last Post: 09-14-2008, 01:49 AM
  3. Pipe problem, popen(), pipe().
    By apacz in forum C Programming
    Replies: 7
    Last Post: 06-08-2006, 12:55 AM
  4. Having trouble with a named pipe
    By crazeinc in forum C Programming
    Replies: 2
    Last Post: 05-13-2005, 01:00 AM
  5. scandir select function
    By dsl24 in forum C Programming
    Replies: 3
    Last Post: 04-12-2002, 10:58 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21