LinuxQuestions.org
Visit the LQ Articles and Editorials section
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
 
LinkBack Search this Thread
Old 10-14-2005, 03:35 AM   #1
zybre_zero
LQ Newbie
 
Registered: Oct 2005
Posts: 3

Rep: Reputation: 0
getservbyport_r function gave diff results


Hi there,

I have a problem with Linux Rehat AS 2.1, 3.0 & 4.0. They gave me a different results when using getservbyport_r function to retreive service name that associated with specific port in /etc/services file.

Here are the simple code that I used to test on each platform.

Quote:
#include <stdio.h>
#include <netdb.h>

#define BUFFER_SIZE 4096


int main(){
int ret;
struct servent se, *pse;
char buffer[BUFFER_SIZE];

ret=getservbyport_r(htons(5100), "udp", &se, buffer, BUFFER_SIZE,&pse);
printf("Return Value= %d \n",ret);
printf("Service Name= %s \n",se.s_name);
return 0;
}
And below are the results that I got from each platforms when it can't match service name with requested port number:

Quote:
Linux Redhat AS 2.1
Return Value= 2 // TRY_AGAIN; defined in /usr/inlcude/netdb.h
Service Name=

Linux Redhat AS 3.0 & 4.0
Return Value= 0 // NETDB_SUCCESS; it return success even though it can't find.
Service Name=
So my question are:
1. Are there any changes in this function behavior between each platform?
2. Where I can find document for this function? As I understand, it is not in man page.


Let me know if you have any ideas. Thanks!!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Linux gave us the kernel 2.6.10. Linux.tar.gz Linux - General 7 12-26-2004 04:10 AM
Dual Boot diff Hard Disk diff OS on Suse 9.1 wilhem Linux - Newbie 1 08-13-2004 06:06 PM
i gave up for a while golpemortal Linux - Laptop and Netbook 1 10-09-2003 10:33 PM
I gave up, pls help samon Linux - Hardware 2 03-30-2003 07:41 PM
Gave up Debian, got slackware nutshell Linux - General 4 07-03-2002 03:10 PM


All times are GMT -5. The time now is 04:39 AM.

Main Menu
 
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
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration