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!!