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

This is a discussion on how to recover when getprotobyname("tcp") fails? within the C++ Programming forums, part of the General Programming Boards category; When getprotobyname("tcp") returns NULL, how do you recover? I tried: Code: while ( ((int)(ptrp = getprotobyname("tcp"))) == 0) { fprintf(stderr, ...

  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, 10: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-06-2006, 12:09 AM
  4. Replies: 0
    Last Post: 05-23-2005, 12:39 PM
  5. HELP - How can I recover deleted file?
    By brett in forum Linux Programming
    Replies: 5
    Last Post: 09-30-2003, 11:10 AM

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