Thread: how to recover when getprotobyname("tcp") fails?

  1. #1
    Registered User
    Join Date
    Oct 2002
    Posts
    72

    how to recover when getprotobyname("tcp") fails?

    When getprotobyname("tcp") returns NULL, how do you recover? I tried:
    Code:
      while ( ((int)(ptrp = getprotobyname("tcp"))) == 0)  {
        fprintf(stderr, "cannot map \"tcp\" to protocol number\n");
        sleep(1);
      }
    but it doesn't seem to get working again until the application trying to connect to this app disconnects.

    Is there a good way to recover from this?

  2. #2
    Evil Member
    Join Date
    Jan 2002
    Posts
    638
    I'm not sure if that specific call has a non-blocking version, (it probably does, most of the networking ones do) but you might consider makeing a thread for it and setting it loose, and having the parent thread run a timeout for it.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 21
    Last Post: 06-24-2009, 09:49 AM
  2. Mac - File locking with fcntl() fails on shared volumes!?
    By idelovski in forum Linux Programming
    Replies: 3
    Last Post: 11-10-2008, 07:37 PM
  3. reasons why malloc fails?
    By prasath in forum C Programming
    Replies: 4
    Last Post: 04-05-2006, 11:09 PM
  4. Replies: 0
    Last Post: 05-23-2005, 11:39 AM
  5. HELP - How can I recover deleted file?
    By brett in forum Linux Programming
    Replies: 5
    Last Post: 09-30-2003, 10:10 AM