LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-24-2002, 06:10 PM   #1
BrianK
Senior Member
 
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334

Rep: Reputation: 51
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?
 
Old 10-25-2002, 06:54 AM   #2
Mik
Senior Member
 
Registered: Dec 2001
Location: The Netherlands
Distribution: Ubuntu
Posts: 1,316

Rep: Reputation: 47
Never used getprotobyname. But I see several things in the man pages about setprotoent and endprotoent. It mentions things about keeping the file open in between calls. If getprotobyname doesn't rewind everytime then the second call would fail unless you called either setprotoent or endprotoent.
I'll leave it to you to figure out what happens when you run these functions.
 
Old 10-25-2002, 01:37 PM   #3
BrianK
Senior Member
 
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334

Original Poster
Rep: Reputation: 51
checking that out... thanks!

Last edited by BrianK; 10-25-2002 at 01:55 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Enable "Netbios over TCP/IP" via dhcpd tisource Linux - Networking 4 11-17-2008 04:13 PM
wget fails when i want to download from a URL which contains "=" or "&' noware Linux - General 7 11-13-2005 07:35 AM
adsl+iptables+port forward+"-m tcp" strange problem icry0000 Linux - Networking 3 07-31-2005 09:31 PM
Recover files after "rm" command on ext2 & fat32 pixelV Linux - Hardware 0 07-14-2003 05:52 AM
How can I recover my RedHat if it BOOTs to a "Kernel Panic" error and stop running? yuzuohong Linux - General 5 12-05-2002 10:39 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:45 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration