Service Resolution

Once your application finds the remote host, it still must locate the particular service it wants to access on that host. Email, file transfer, and web sites are all services. For the ease of users, these services are given well-known names such as “smtp,” “ftp,” or “http.” For the ease of computers, these services are assigned a 16-bit integer port number.

Service resolution provides the mapping between well-known service names and their respective port number. The Palm OS Net Library supports service resolution only as far as retrieving the service information by name. It does not support retrieving this information by port number, which is supported by many other sockets implementations.

NetServInfoType

Service information is returned in the NetServInfoType structure. This structure corresponds to the Berkeley Sockets’ servent structure.

typedef struct {
   Char*    nameP;
   Char**   nameAliasesP;
   UInt16   port;
   Char*    protoP;
   } NetServInfoType, *NetServInfoPtr;

The attributes of this structure are described in Table 7-7.

Table 7-7. Attributes of the NetServInfoType structure

Attribute

Size

Purpose

nameP

2

Points to `C’ string containing official service name.

nameAliasesP

2

Points to NULL-terminated array of pointers, and to `C’ strings containing alternate service names.

port

2

Port number assigned to the service.

protoP

2

Name of the transport protocol over which the service runs.

Total Size

8

Figure 7-3 shows the arrangement of this structure in ...

Get Palm OS Network Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.