Alan Berg

Greenhorn
+ Follow
since Apr 11, 2001
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Alan Berg

In Linux the c function getservbyname is in the netdb.h header file.
#include <netdb.h>
struct servent *getservent(void);
struct servent *getservbyname(const char *name, const char *proto);
struct servent *getservbyport(int port, const char *proto);
void setservent(int stayopen);
void endservent(void);
DESCRIPTION
The getservbyname() function returns a servent
structure for the line from /etc/services that matches
the service name using protocol proto.
The servent structure is defined in <netdb.h> as follows:
struct servent {
char *s_name; /* official service name */
char **s_aliases; /* alias list */
int s_port; /* port number */
char *s_proto; /* protocol to use */
}
I am using TCP protocol for my client. How can I get the port number of the ServerSocket to create the client socket if I only know the server's hostName and/or InetAddress. I can get the port address of the server in c with the function 'getservbyname', is there a java equivalent method? or is there another way?