NetMgr.h
declares the net library API. The chapter covers:
IMPORTANT: Applications cannot directly use the net library to make wireless connections. Use the INetLib for wireless connections.
NetHostInfoBufType
struct contains information about a host. The
NetHostInfoType
struct, which maps to the hostent
struct, points to fields in this struct for its information.
typedef struct {
    NetHostInfoType hostInfo;
    Char name[netDNSMaxDomainName+1];
    Char * aliasList[netDNSMaxAliases+1];
    Char aliases[netDNSMaxAliases]
[netDNSMaxAliases+1];
    NetIPAddr* addressList[netDNSMaxAddresses];
    NetIPAddr address[netDNSMaxAddresses];
} NetHostInfoBufType, *NetHostInfoBufPtr;
NetHostInfoType
structure maps to the Berkeley UNIX sockets hostent
structure. It is defined as follows:
typedef struct {
    Char * nameP;
    Char ** nameAliasesP;
    UInt16 addrType;
    UInt16 addrLen;
    UInt8 ** addrListP;
} NetHostInfoType, *NetHostInfoPtr;
NetServInfoBufType
struct contains information about a service. The
NetServInfoType
struct, which maps to the servent
struct, points to fields in this struct for much of its information.
struct {
    NetServInfoType servInfo;
    Char name[netServMaxName+1];
    Char * aliasList[netServMaxAliases+1];
    Char aliases[netServMaxAliases] [netServMaxName];
    Char protoName[netProtoMaxName+1];
    UInt8 reserved;
} NetServInfoBufType, *NetServInfoBufPtr;
NetServInfoType
structure maps to the servent
structure in Berkeley UNIX sockets API. It contains information about a service.
struct {
    Char * nameP;
    Char ** nameAliasesP;
    UInt16 port;
    Char * protoP;
} NetServInfoType, *NetServInfoPtr;
nameP
| Official name of the service |
nameAliasesP
| Array of aliases for the service name. |
port
| Port number for the service. |
protoP
| Name of the protocol to use. |
NetSocketAddrEnum
enum specifies the address types supported by the net library.
typedef enum {
    netSocketAddrRaw = 0,
    netSocketAddrINET = 2
} NetSocketAddrEnum
netSocketAddrRaw
| Raw address. Supported in Palm OS® version 3.0 and higher. |
netSocketAddrINET
| IP address. |
NetSocketAddrINType
struct holds an internet socket address, that is, a socket that uses one of the internet protocols. This structure directly maps to the BSD UNIX sockaddr_in
structure.
typedef struct NetSocketAddrINType {
    Int16 family;
    UInt16 port;
    NetIPAddr addr;
} NetSocketAddrINType;
family
|
Address family in host byte order. This is either netSocketAddrINET or netSocketAddrRaw .
|
port
| The port in network byte order. |
addr
| The IP address in network byte order. |
NetSocketAddrRawType
structure holds a raw socket address.
typedef struct NetSocketAddrRawType {
    Int16 family;
    UInt16 ifInstance;
    UInt32 ifCreator;
} NetSocketAddrRawType;
NetSocketAddrType
structure holds a generic socket address. This struct can hold any type of address including Internet addresses. It directly maps to the BSD UNIX sockaddr
structure.
NetSocketAddrINType
and NetSocketAddrRawType
. This means that one of those two structures can be used for parameters declared to be NetSocketAddrType
.
typedef struct NetSocketAddrType {
    Int16 family;
    UInt8 data[14];
} NetSocketAddrType;
NetSocketRef
defines a socket descriptor. The socket descriptor is created and returned by
NetLibSocketOpen
. It is used in any function that requires access to a socket.
typedef Int16 NetSocketRef
NetSocketTypeEnum
enum specifies the available socket types.
typedef enum {
    netSocketTypeStream=1,
    netSocketTypeDatagram=2,
    netSocketTypeRaw=3,
    netSocketTypeReliableMsg=4
} NetSocketTypeEnum
netSocketTypeStream
| Streams protocol over wireline. |
netSocketTypeDatagram
| UDP protocol. |
netSocketTypeRaw
| Raw mode. |
NetLibMaster
call.
NetLibIFSettingSet
and for the net library in general with
NetLibSettingSet
.
NetHToNL (x)
x
in network byte order.
htonl()
NetNToHS
,
NetNToHL
,
NetHToNS
NetHToNS (x)
x
in network byte order.
htons()
NetNToHS
,
NetNToHL
,
NetHToNL
NetIPAddr NetLibAddrAToIN (UInt16 libRefnum, Char *a)
  |
-> |
Reference number of the net library. |
  |
-> |
Pointer to ASCII dotted decimal string. |
a
doesn't represent a dotted decimal IP address
UInt32 inet_addr(char* cp)
NetLibAddrINToA
Char * NetLibAddrINToA (UInt16 libRefnum, NetIPAddr inet, Char *spaceP)
  |
-> |
Reference number of the net library. |
  |
-> |
32-bit IP address in network byte order. |
  |
<- |
Buffer used to hold the return value. |
spaceP
the dotted decimal ASCII string representation of the IP address.
char* inet_ntoa(struct in_addr in)
NetLibAddrAToIN
Err NetLibClose (UInt16 libRefnum, UInt16 immediate)
  |
-> |
Reference number of the net library. |
  |
-> |
If true , library will shut down immediately. If false , library will shut down only if close timer expires before another NetLibOpen is issued. |
netErrStillOpen
is returned. If the open count was 1, the library takes the following action:
immediate
is true
, the library shuts down immediately. All network interfaces are brought down, the net protocol stack task is terminated, and all memory used by the net library is freed. immediate
is false
, a close timer is created and this call returns immediately without actually bringing the net library down. Instead it leaves it up and running but marks it as in the "close-wait" state. It remains in this state until either the timer expires or another NetLibOpen
is issued. If the timer expires, the library is shut down. If another NetLibOpen
call is issued before the timer expires (possibly by another application), the timer is cancelled and the library is marked as fully open.false
for immediate
. This allows the user to quit one Internet application and launch another within a short period of time without having to wait through the process of closing down and then re-establishing dial-up network connections.
NetLibOpen
,
NetLibOpenCount
Err NetLibConnectionRefresh (UInt16 refNum, Boolean refresh, UInt8 *allInterfacesUpP, UInt16 * netIFErrP)
  |
|
Reference number of the net library. |
  |
|
If true , any connections that aren't currently open are opened. |
  |
|
Set to true if all connections are open. |
  |
|
First error encountered when reopening connections that were closed. (See NetLibIFUp for a list of possible values.) |
Int16 NetLibDmReceive (UInt16 libRefNum, NetSocketRef socket, void* recordP, UInt32 recordOffset, UInt16 rcvLen, UInt16 flags, void* fromAddrP, UInt16 *fromLenP, Int32 timeout, Err* errP)
  |
-> |
Reference number of the net library. |
  |
-> |
Descriptor for the open socket. |
  |
<- |
Pointer to beginning of record to receive data into. Must be locked for use. |
  |
-> |
Offset from beginning of record to read data into. |
  |
-> |
Maximum number of bytes to read. |
  |
-> |
One or more netIOFlagxxx flags. See "I/O Flags." |
  |
<- |
Pointer to buffer to hold address of sender (a NetSocketAddrType struct). Pass NULL if you don't need sender information. |
  |
<-> |
On entry, size of fromAddrP buffer. On exit, actual size of returned address in fromAddrP . Pass NULL if you don't need sender information. |
  |
-> |
Maximum timeout in system ticks; -1 means wait forever. |
  |
<- |
Contains an error code if the return value is -1. |
errP
contains one of the following values:
  |
0 |
No error. |
  |
|
Call timed out. |
  |
|
The referenced net library has not been opened yet. |
netErrParamErr
netErrSocketNotOpen
netErrWouldBlock
netErrUserCancel
netErrOutOfMemory
NetLibReceive
but reads the data directly into a database record, which is normally write-protected. The caller must pass a pointer to the start of the record and an offset into the record of where to start the read.
Err NetLibFinishCloseWait (UInt16 libRefnum)
NetLibClose
), it forces the library to perform an immediate, complete close operation.
NetHostInfoPtr NetLibGetHostByAddr (UInt16 libRefnum, UInt8 *addrP, UInt16 len, UInt16 type, NetHostInfoBufPtr bufP, Int32 timeout, Err *errP)
  |
-> |
Reference number of the net library. |
  |
-> |
IP address of host to lookup. |
  |
-> |
Length, in bytes, of *addrP . |
  |
-> |
Type of addrP . See NetSocketAddrEnum . |
  |
<- |
Pointer to a NetHostInfoBufType struct in which to store the results of the lookup. |
  |
-> |
Maximum timeout in system ticks; -1 means wait forever. |
  |
<- |
Contains an error code if the return value is 0. |
NetHostInfoType
portion of bufP
that contains results of the lookup. If the return value is 0, an error has occurred, and errP
contains one of the following values:
  |
0 |
No error |
  |
|
Call timed out. |
  |
|
The referenced net library has not been opened yet. |
etErrDNSNameTooLong
netErrDNSBadName
netErrDNSLabelTooLong
netErrDNSAllocationFailure
netErrDNSTimeout
netErrDNSUnreachable
netErrDNSFormat
netErrDNSServerFailure
netErrDNSNonexistantName
netErrDNSNIY
netErrDNSRefused
netErrDNSImpossible
netErrDNSNoRRS
netErrDNSAborted
netErrDNSBadProtocol
netErrDNSTruncated
netErrDNSNoRecursion
netErrDNSIrrelevant
netErrDNSNotInLocalCache
netErrDNSNoPort
struct hostent* gethostbyaddr (char* addr, int len, int type);
NetLibGetHostByName
NetHostInfoPtr NetLibGetHostByName (UInt16 libRefnum, Char *nameP, NetHostInfoBufPtr bufP, Int32 timeout, Err *errP)
  |
-> |
Reference number of the net library. |
  |
-> |
Name of host to look up. |
  |
<- |
Pointer to a NetHostInfoBufType struct in which to store the results of the lookup. |
  |
-> |
Maximum timeout in system ticks; -1 means wait forever. |
  |
<- |
Contains an error code if the return value is 0. |
NetHostInfoType
portion of bufP
, which contains results of the lookup. If the return value is 0, an error has occurred and errP
contains one of the following values:
  |
0 |
No error |
  |
|
Call timed out. |
  |
|
The referenced net library has not been opened yet. |
etErrDNSNameTooLong
netErrDNSBadName
netErrDNSLabelTooLong
netErrDNSAllocationFailure
netErrDNSTimeout
netErrDNSUnreachable
netErrDNSFormat
netErrDNSServerFailure
netErrDNSNonexistantName
netErrDNSNIY
netErrDNSRefused
netErrDNSImpossible
netErrDNSNoRRS
netErrDNSAborted
netErrDNSBadProtocol
netErrDNSTruncated
netErrDNSNoRecursion
netErrDNSIrrelevant
netErrDNSNotInLocalCache
netErrDNSNoPort
struct hostent *gethostbyname(char* name);
NetLibGetHostByAddr
,
NetLibGetMailExchangeByName
Int16 NetLibGetMailExchangeByName (UInt16 libRefNum, Char *mailNameP, UInt16 maxEntries, Char hostNames[][netDNSMaxDomainName+1], UInt16 priorities[], Int32 timeout, Err* errP)
  |
-> |
Reference number of the net library. |
  |
-> |
Name of the mail exchange to look up. |
  |
-> |
Maximum number of host names to return. |
  |
<- |
Array of character strings of length netDNSMaxDomainName+1 . The host name results are stored in this array. This array must be able to hold at least maxEntries host names. |
  |
<- |
Array of Word s. The priorities of each host name found are stored in this array. This array must be at least maxEntries in length. |
  |
-> |
Maximum timeout in system ticks; -1 means wait forever. |
  |
<- |
Contains an error code if the return value is less than 0. |
errP
contains one of the following values:
  |
0 |
No error |
  |
|
Call timed out. |
  |
|
The referenced net library has not been opened yet. |
netErrDNSNameTooLong
netErrDNSBadName
netErrDNSLabelTooLong
netErrDNSAllocationFailure
netErrDNSTimeout
netErrDNSUnreachable
netErrDNSFormat
netErrDNSServerFailure
netErrDNSNonexistantName
netErrDNSNIY
netErrDNSRefused
netErrDNSImpossible
netErrDNSNoRRS
netErrDNSAborted
netErrDNSBadProtocol
netErrDNSTruncated
netErrDNSNoRecursion
netErrDNSIrrelevant
netErrDNSNotInLocalCache
netErrDNSNoPort
mailNameP
and gets back a list of host names to which the mail message can be sent.
NetLibGetHostByAddr
,
NetLibGetHostByName
NetServInfoPtr NetLibGetServByName (UInt16 libRefnum, const Char *servNameP, const Char *protoNameP, NetServInfoBufPtr bufP, Int32 timeout, Err* errP)
  |
-> |
Reference number of the net library. |
  |
-> |
Desired protocol to use, either "udp" or "tcp". |
  |
<- |
Pointer to a NetServInfoBufType struct in which to store the results of the lookup. |
  |
-> |
Maximum timeout in system ticks; -1 means wait forever. |
  |
<- |
Contains an error code if the return value is 0. |
NetServInfoType
portion of bufP
that contains results of the lookup. If the return value is 0, and error has occurred and errP
contains one of the following values:
  |
0 |
No error |
  |
|
Call timed out. |
  |
|
The referenced net library has not been opened yet. |
netErrUnknownProtocol
netErrUnknownService
struct servent* getservbyname(char* addr, char* proto);
NetLibGetHostByName
Err NetLibIFAttach (UInt16 libRefnum, UInt32 ifCreator, UInt16 ifInstance, Int32 timeout)
  |
-> |
Reference number of the net library. |
  |
-> |
Creator of interface to attach. |
  |
-> |
Instance number of interface to attach. The instance number is one of the values returned by NetLibIFGet . |
  |
-> |
Timeout in ticks; -1 means infinite timeout. |
'neti'
. The ifCreator
parameter to this function is used to locate the network interface database of the given creator.
NetLibIFGet
,
NetLibIFDetach
Err NetLibIFDetach (UInt16 libRefnum, UInt32 ifCreator, UInt16 ifInstance, Int32 timeout)
  |
-> |
Reference number of the net library. |
  |
-> |
Creator of interface to detach. |
  |
-> |
Instance number of interface to detach. |
  |
-> |
Timeout in ticks; -1 means infinite timeout. |
NetLibIFGet
,
NetLibIFAttach
Err NetLibIFDown (UInt16 libRefnum, UInt32 ifCreator, UInt16 ifInstance, Int32 timeout)
  |
-> |
Reference number of the net library. |
  |
-> |
Creator of interface to attach. |
  |
-> |
Instance number of interface to attach. |
  |
-> |
Timeout in ticks; -1 means wait forever. |
NetLibClose
automatically brings down any attached interfaces, so this routine doesn't normally have to be called.
NetLibIFGet
,
NetLibIFAttach
,
NetLibIFDetach
,
NetLibIFUp
Err NetLibIFGet (UInt16 libRefnum, UInt16 index, UInt16 * ifCreatorP, UInt16 * ifInstanceP)
  |
-> |
Reference number of the net library. |
  |
-> |
Index of the interface to get. Indices start at 0. |
  |
<- |
The interface's creator. |
  |
<- |
The interface's instance number. |
netErrInvalidInterface
is returned.
ifCreator
and ifInstance
values returned from this call can then be used with the
NetLibSettingGet
call to get more information about that particular interface.
NetLibIFAttach
,
NetLibIFDetach
, "Settings for Interface Selection" in the Palm OS Programmer's Companion
Err NetLibIFSettingGet (UInt16 libRefnum, UInt32 ifCreator, UInt16 ifInstance, UInt16 setting, void *valueP, UInt16 *valueLenP)
  |
-> |
Reference number of the net library. |
  |
-> |
Creator of the network interface. |
  |
-> |
Instance number of the network interface. |
  |
-> |
Setting to retrieve; one of the NetIFSettingEnum constants. |
  |
<- |
Space for return value of setting. |
  |
<-> |
On entry, size of valueP . On exit, actual size of setting. |
  |
0 |
Success. |
  |
|
Invalid setting constant. |
  |
|
No current value for setting. |
  |
|
valueP was too small to hold entire setting. Setting value was truncated to fit in valueP . |
netErrUnimplemented
netErrInterfaceNotFound
netErrBufWrongSize
P
), the size of the buffer (*valueLenP
), and the setting ID (setting
). The setting ID is one of the constants in the NetIFSettingEnum
type.
*valueLenP
. The required size is returned in valueLenP
.
netIFSetting... | Type | Description |
---|---|---|
ResetAll | void |
Use with NetLibIFSettingSet only. This clears all other settings for the interface to their default values.
|
Up | UInt8 |
Read-only. true if interface is currently up.
|
Name | Char[32] | Read-only. Name of this interface. |
ReqIPAddr | UInt32 | IP address of interface. |
SubnetMask | UInt32 | Subnet mask for interface. Doesn't need to be specified for PPP or SLIP type connections. |
Broadcast | UInt32 | Broadcast address for interface. Doesn't need to be specified for PPP or SLIP type connections. |
Username | Char[32] |
User name. Only required if the login script uses the user name substitution escape sequence in it. Call NetLibIFSettingSet with a valueLen of 0 to remove this setting.
|
Password | Char[32] |
Password. Only required if the login script uses the password substitution escape sequence in it. Call NetLibIFSettingSet with a valueLen of 0 to remove this setting. If the login script uses password substitution and no password setting is set, the user will be prompted for a password at connect time.
|
AuthUsername | Char[32] |
Authentication user name. Only required if the authentication protocol uses a different user name than the what's in the netIFSettingUsername setting. If this setting is empty (valueLen of 0), the Username setting will be used instead. Call NetLibIFSettingSet with a valueLen of 0 to remove this setting.
|
AuthPassword | Char[32] |
Authentication password. If "$" then the user will be prompted for the authentication password at connect time. Else, if 0 length, then the netIFSettingPassword setting or the result of its prompt will be used instead. Call NetLibIFSettingSet with a valueLen of 0 to remove this setting.
|
ServiceName | Char[] |
Service name. Used for display purposes while showing the connection progress dialog box. Call NetLibIFSettingSet with a valueLen of 0 to remove this setting.
|
LoginScript | Char[] |
Login script. Only required if the particular service requires a login sequence. Call NetLibIFSettingSet with a valueLen of 0 to remove this setting. See below for a description of the login script format.
|
ConnectLog | Char[] |
Connect log. Generally, this setting is just retrieved, not set. It contains a log of events from the most recent login. To clear this setting, call NetLibIFSettingSet with a valueLen of 0.
|
InactivityTimeout | UInt16 | Maximum number of seconds of inactivity allowed. Set to 0 to ignore. |
EstablishmentTimeout | UInt16 | Maximum delay, in seconds, allowed between each stage of connection establishment or login script line. Must be non-zero. |
DynamicIP | UInt8 |
If non-zero, negotiate for an IP address. If false , the IP address specified in the netIFSettingReqIPAddr setting will be used. Default is false .
|
VJCompEnable | UInt8 |
If non-zero, enable VJ header compression. Default is true for PPP, false for SLIP, and true for CSLIP.
|
VJCompSlots | UInt8 | Number of slots to use for VJ compression. Default is 4 for PPP and 16 for SLIP and CSLIP. More slots require more memory so it is best to keep this number to a minimum. |
MTU | UInt16 | Maximum transmission unit in octets. Currently not implemented in SLIP or PPP. |
AsyncCtlMap | UInt32 | Bit mask of characters to escape for PPP. Default is 0. |
PortNum | UInt16 | Which serial communication port to use. Port 0 is the only port available on the device. |
BaudRate | UInt32 | Serial port baud rate to use in bits per second. |
FlowControl | UInt8 | If bit 0 is 1, use hardware handshaking on the serial port. Default is no hardware handshaking. |
StopBits | UInt8 | Number of stop bits. Default is 1. |
ParityOn | UInt8 |
true if parity detection enabled. Default is false .
|
ParityEven | UInt8 |
true for even parity detection. Default is true .
|
UseModem | UInt8 |
If true , dial-up through modem. If false , go direct over serial port
|
PulseDial | UInt8 |
If true , pulse dial modem. Else, tone dial. Default is tone dial.
|
ModemInit | Char[] |
Zero-terminated modem initialization string, not including the "AT". If not specified (valueLen of 0), the modem initialization string from system preferences are used.
|
ModemPhone | Char[] |
Zero-terminated modem phone number string. Only required if netIFSettingUseModem is true.
|
RedialCount | UInt16 |
Number of times to redial modem when trying to establish a connection. Only required if netIFSettingUseModem is true.
|
DNSQuery | UInt8 |
true if PPP queries for DNS address. The default is true .
|
TraceBits | UInt32 | A bitfield of various trace bits. See "Tracing Bits." |
ActualIPAddr | UInt32 | Read-only. The actual IP address that the interface ends up using. The login script execution engine stores the result of the "g" (get IP address) command here as does the PPP negotiation logic. |
ServerIPAddr | UInt32 | Read-only. The IP address of the PPP server we're connected to. |
BringDownOnPowerDown | UInt8 |
true if the interface is brought down when the Palm OS® device is turned off.
|
RawMode | UInt32 | Specifies if the interface is in raw mode. The net library places an interface in raw mode when it is bound to a raw socket in the raw domain. Raw sockets are available in Palm OS version 3.0 and higher. |
NetLibIFSettingSet
,
NetLibSettingGet
,
NetLibSettingSet
, "Interface Specific Settings" in the Palm OS Programmer's Companion
Err NetLibIFSettingSet (UInt16 libRefnum, UInt32 ifCreator, UInt16 ifInstance, UInt16 setting, void* valueP, UInt16 valueLen)
  |
-> |
Reference number of the net library. |
  |
-> |
Creator of the network interface. |
  |
-> |
Instance number of the network interface. |
  |
-> |
The setting to set, one of the NetIFSettingEnum constants. See Table 54.1. |
  |
-> |
Space new value of setting. |
  |
-> |
Size of new setting. |
  |
0 |
Success. |
  |
|
Invalid setting constant. |
  |
|
No current value for setting. |
  |
|
valueP was too small to hold entire setting. Setting value was truncated to fit in valueP . |
netErrUnimplemented
netErrInterfaceNotFound
netErrBufWrongSize
netErrReadOnlySetting
valueP
), the size of the buffer (valueLen
), and the setting ID (setting
).
NetLibIFSettingGet
for an explanation of each of the settings.
netIFSettingResetAll
setting, which, if used, resets all settings for the interface to their default values. When using this setting, valueP
and valueLen
are ignored.
NetLibIFSettingGet
,
NetLibSettingGet
,
NetLibSettingSet,
"Interface Specific Settings" in the Palm OS Programmer's Companion
Err NetLibIFUp (UInt16 libRefnum, UInt32 ifCreator, UInt16 ifInstance)
  |
-> |
Reference number of the net library. |
  |
-> |
Creator of interface to attach. |
  |
-> |
Instance number of interface to attach. |
NetLibIFGet
,
NetLibIFAttach
,
NetLibIFDetach
,
NetLibIFDown
Err NetLibMaster (UInt16 libRefnum, UInt16 cmd, NetMasterPBPtr pbP, Int32 timeout)
  |
-> |
Reference number of the net library. |
  |
-> |
Function to perform (NetMasterEnum type). The following commands are supported: |
  |
<-> |
Command parameter block. |
  |
-> |
Timeout in ticks; -1 means wait forever. |
cmd
) and parameter block pointer (pbP
) as arguments and returns its results in the parameter block on exit. Which values you must specify in the parameter block and which values are returned are specific to the command you specify.
pbP->interfaceInfo
struct specifies interface information.
pbP->interfaceStats
structure specifies interface statistics.
pbP->ipStats
structure contains statistics about the IP protocol. See NetMgr.h
for a complete list of statistics returned.
pbP->icmpStats
structure contains statistics about the ICMP protocol. See NetMgr.h
for a complete list of statistics returned.
pbP->udpStats
structure contains statistics about the UDP protocol. See NetMgr.h
for a complete list of statistics returned.
pbP->tcpStats
structure contains statistics about the TCP protocol. See NetMgr.h
for a complete list of statistics returned.
Err NetLibOpen (UInt16 libRefnum, UInt16 *netIFErrP)
  |
-> |
Reference number of the net library. |
  |
<- |
First error encountered when bringing up network interfaces. (See NetLibIFUp for a list of possible values.) |
  |
0 |
No error. |
  |
|
Not really an error; returned if library was already open and the open count was simply incremented. |
  |
n |
Not enough memory available to open the library. |
  |
|
Incorrect setup. |
  |
|
Incorrect setup. |
NetLibOpen
increments its open count. Otherwise, it opens the library, initializes it, starts up the net protocol stack component of the library as a separate task, and brings up all attached network interfaces.
NetLibOpen
uses settings saved in the net library's preferences database during initialization. These settings include the interfaces to attach, the IP addresses, etc. It's assumed that these settings have been previously set up by a preference panel or equivalent so an application doesn't normally have to set them up before calling NetLibOpen
.
netIFErrP
will contain the error number of the first interface that encountered a problem.
SysLibFind
,
NetLibClose
,
NetLibOpenCount
Err NetLibOpenCount (UInt16 libRefnum, UInt16 *countP)
  |
-> |
Reference number of the net library. |
  |
<- |
Contains the open count of the net library upon return. |
NetLibOpen
unconditionally during startup and
NetLibClose
when they exit.
Int16 NetLibReceive (UInt16 libRefNum, NetSocketRef socket, void* bufP, UInt16 bufLen, UInt16 flags, void* fromAddrP, UInt16 * fromLenP, Int32 timeout, Err* errP);
  |
-> |
Reference number of the net library. |
  |
-> |
Descriptor for the open socket. |
  |
<- |
Pointer to buffer to hold received data. |
  |
-> |
Length of bufP buffer. |
  |
-> |
One or more netIOFlagxxx flags. See "I/O Flags." |
  |
<- |
Pointer to buffer to hold address of sender (a NetSocketAddrType ). |
  |
<-> |
On entry, size of fromAddrP buffer. On exit, actual size of returned address in fromAddrP . |
  |
-> |
Maximum timeout in system ticks; -1 means wait forever. |
  |
<- |
Contains an error code if the return value is -1. |
errP
contains one of the following values:
  |
0 |
No error. |
  |
|
Call timed out. |
  |
|
The referenced net library has not been opened yet. |
netErrParamErr
netErrSocketNotOpen
netErrWouldBlock
netErrUserCancel
int recvfrom (int socket, const void* bufP, int bufLen, int flags, const void* fromAddrP, int* fromLenP);
int recv(int socket, const void* bufP, int bufLen, int flags);
int read(int socket, const void* bufP, int bufLen);
bufP
.
NetLibReceive
,
NetLibDmReceive
,
NetUReadN
,
NetLibSend
,
NetLibSendPB
Int16 NetLibReceivePB (UInt16 libRefnum, NetSocketRef socket, NetIOParamType* pbP, UInt16 flags, Int32 timeout, Err* errP)
  |
-> |
Reference number of the net library. |
  |
-> |
Descriptor for the open socket. |
  |
-> |
Pointer to parameter block containing buffer info. |
  |
-> |
One or more netIOFlagxxx flags. See "I/O Flags." |
  |
-> |
Maximum timeout in system ticks; -1 means wait forever. |
  |
<- |
Contains an error code if the return value is -1. |
errP
contains one of the following values:
  |
0 |
No error. |
  |
|
Call timed out. |
  |
|
The referenced net library has not been opened yet. |
netErrParamErr
netErrSocketNotOpen
netErrWouldBlock
int recvmsg (int socket, const struct msghdr* pbP, int flags);
pbP
parameter is a pointer to a NetIOParamType
structure. NetIOParamType
is defined as follows:
typedef struct {
    UInt8 * addrP;
    UInt16 addrLen;
    NetIOVecPtr iov;
    UInt16 iovLen;
    UInt8 * accessRights;
    UInt16 accessRightsLen;
} NetIOParamType, *NetIOParamPtr;
pbP->iov
array.
NetLibReceive
,
NetLibDmReceive
,
NetLibSend
,
NetLibSendPB
Int16 NetLibSelect (UInt16 libRefnum, UInt16 width, NetFDSetType* readFDs, NetFDSetType* writeFDs, NetFDSetType* exceptFDs, Int32 timeout, Err* errP)
  |
-> |
Reference number of the net library. |
  |
-> |
Number of descriptor bits to check in the readFDs , writeFDs , and exceptFDs descriptor sets. |
  |
<-> |
Pointer to 32-bit NetFDSetType containing set of bits representing descriptors to check for input. |
  |
<-> |
Pointer to 32-bit NetFDSetType containing set of bits representing descriptors to check for output. |
  |
<-> |
Pointer to 32-bit NetFDSetType containing set of bits representing descriptors to check for exception conditions. This parameter is ignored. Upon return, its bits are always cleared. |
  |
-> |
Maximum timeout in system ticks; -1 means wait forever. |
  |
<- |
Contains an error code if the return value is -1. |
readFDs
, *writeFDs
, and *exceptFDs
. Returns 0 upon timeout. If the return value is -1, an error has occurred, and errP
contains one of the following values:
  |
0 |
No error |
  |
|
Call timed out. |
  |
|
The referenced net library has not been opened yet. |
int select (int width, fd_set* readfds, fd_set* writefds, fd_set* exceptfds, struct timeval* timeout);
NetSocketRef
or the "stdin" descriptor, sysFileDescStdIn
. The sysFileDescStdIn
descriptor will be ready for input whenever a user event is available like a pen tap or key press.
netFDZero
and netFDSet
macros. After this call returns, the macro netFDIsSet
can be used to determine which descriptors in each set are actually ready.
    Err err;
    NetSocketRef socket;
    NetFDSetType readFDs,writeFDs,exceptFDs;
    Int16 numFDs;
    UInt16 width;
    // Create the descriptor sets
    netFDZero(&readFDs);
    netFDZero(&writeFDs);
    netFDZero(&exceptFDs);
    netFDSet(sysFileDescStdIn, &readFDs);
    netFDSet(socket, &readFDs);
    // Calculate the max descriptor number and
    // use that +1 as the max width.
    // Alternatively, we could simply use the
    // constant netFDSetSize as the width which
    // is simpler but makes the NetLibSelect call
    // slightly slower.
    width = sysFileDescStdIn;
    if (socket > width) width = socket;
    // Wait for any one of the descriptors to be
    // ready.
    numFDs = NetLibSelect(AppNetRefnum, width+1,
    &readFDs, &writeFDs, &exceptFDs,
    AppNetTimeout, &err);
NetSample
example application in the Palm OS Examples
folder. The function CmdTelnet
in the file CmdTelnet.c
shows how to use the Berkeley sockets select
function and how to interpret the results.
NetLibSocketOptionSet
Int16 NetLibSend (UInt16 libRefNum, NetSocketRef socket, void* bufP, UInt16 bufLen, UInt16 flags, void* toAddrP, UInt16 toLen, Int32 timeout, Err* errP)
  |
-> |
Reference number of the net library. |
  |
-> |
Descriptor for the open socket. |
  |
-> |
Pointer to data to write. |
  |
-> |
Length of data to write |
  |
-> |
One or more netIOFlagxxx flags. See "I/O Flags." |
  |
-> |
Address to send to (a pointer to a NetSocketAddrType ), or 0. |
  |
-> |
Size of toAddrP buffer. |
  |
-> |
Maximum timeout in system ticks; -1 means wait forever. |
  |
<- |
Contains an error code if the return value is -1. |
errP
contains one of the following values:
  |
0 |
No error. |
  |
|
Call timed out. |
  |
|
The referenced net library has not been opened yet. |
netErrParamErr
netErrSocketNotOpen
netErrMessageTooBig
netErrSocketNotConnected
netErrSocketClosedByRemote
netErrIPCantFragment
netErrIPNoRoute
netErrIPNoSrc
netErrIPNoDst
netErrIPktOverflow
netErrOutOfCmdBlocks
netErrOutOfPackets
netErrInterfaceNotFound
netErrInterfaceDown
netErrUnreachableDest
netErrNoMultiPktAddr
netErrWouldBlock
int sendto(int socket, const void* bufP, int bufLen, int flags, const void* toAddrP, int toLen);
int send(int socket, const void* bufP, int bufLen, int flags);
int write(int socket, const void* bufP, int bufLen,);
bufP
points to.
toAddrP
field applies only to datagram sockets without an existing connection. An error is returned if the datagram socket was previously connected and toAddrP
is specified. Stream-based sockets, by definition, must have a connection established with a remote host before data can be written. Raw sockets (supported in Palm OS version 3.0 and higher) must construct the entire IP header, including the destination address, before data can be sent; thus, the address is taken from the data to be sent.
NOTE:  For stream-based sockets, this call may write only a portion of the desired data. It always returns the number of bytes actually written. Consequently, the caller should be prepared to call this routine repeatedly until the desired number of bytes have been written, or until it returns 0 or -1.
NetLibSendPB
,
NetUWriteN
,
NetLibReceive
,
NetLibReceivePB
,
NetLibDmReceive
Int16 NetLibSendPB (UInt16 libRefnum, NetSocketRef socket, NetIOParamType* pbP, UInt16 flags, Int32 timeout, Err* errP)
  |
-> |
Reference number of the net library. |
  |
-> |
Descriptor for the open socket. |
  |
-> |
Pointer to parameter block containing buffer info. See the description in NetLibReceivePB . |
  |
-> |
One or more netIOFlagxxx flags. See "I/O Flags." |
  |
-> |
Maximum timeout in system ticks; -1 means wait forever. |
  |
<- |
Contains an error code if the return value is -1. |
errP
contains one of the following values:
  |
0 |
No error. |
  |
|
Call timed out. |
  |
|
The referenced net library has not been opened yet. |
netErrParamErr
netErrSocketNotOpen
netErrMessageTooBig
netErrSocketNotConnected
netErrSocketClosedByRemote
netErrIPCantFragment
netErrIPNoRoute
netErrIPNoSrc
netErrIPNoDst
netErrIPktOverflow
netErrOutOfCmdBlocks
netErrOutOfPackets
netErrInterfaceNotFound
netErrInterfaceDown
netErrUnreachableDest
netErrNoMultiPktAddr
netErrWouldBlock
int sendmsg(int socket, const struct msghdr* pbP, int flags);
pbP
parameter block.
toAddrP
field applies only to datagram sockets without an existing connection. An error is returned if the datagram socket was previously connected and toAddrP
is specified. Stream-based sockets, by definition, must have a connection established with a remote host before data can be written. Raw sockets (supported in Palm OS version 3.0 and higher) must construct the entire IP header, including the destination address, before data can be sent; thus, the address is taken from the data to be sent.
NOTE:  For stream-based sockets, this call may write only a portion of the desired data. It always returns the number of bytes actually written. Consequently, the caller should be prepared to call this routine repeatedly until the desired number of bytes have been written, or until it returns 0 or -1.
NetLibSend
,
NetLibReceive
,
NetLibReceivePB
,
NetLibDmReceive
Err NetLibSettingGet (UInt16 libRefnum, UInt16 setting, void* valueP, UInt16* valueLenP)
  |
-> |
Reference number of the net library. |
  |
-> |
Setting to retrieve, one of the NetSettingEnum constants. |
  |
<- |
Space for return value of setting. |
  |
<-> |
On entry, size of valueP . On exit, actual size of setting. |
valueP
), the size of the buffer (*valueLenP
), and the setting ID (setting
). The setting ID is one of the NetSettingEnum
constants in the netSettingEnum
type.
*valueLenP
. The required size is returned in valueLenP
.
netSetting... | Type | Description |
---|---|---|
ResetAll | void |
Used for NetLibSettingSet only. This will clear all other settings to their default values.
|
PrimaryDNS | UInt32 | IP address of primary DNS server. This setting must be set to a non-zero IP address in order to support any of the name lookup calls. |
SecondaryDNS | UInt32 | IP address of secondary DNS server. Set to 0 to have stack ignore this setting. |
DefaultRouter | UInt32 |
IP address of default router. Default value is 0 which is appropriate for most implementations with only one attached interface (besides loopback). Packets with destination IP addresses that don't lie in the subnet of an attached interface will be sent to this router through the default interface specified by the netSettingDefaultIFCreator /netSettingDefaultIFInstance pair.
|
DefaultIFCreator | UInt32 | Creator of the default network interface. Default value is 0, which is appropriate for most implementations. Packets with destination IP addresses that don't lie in the subnet of a directly attached interface are sent through this interface. If this setting is 0, the stack automatically makes the first non-loopback interface the default interface. |
DefaultIFInstance | UInt16 | Instance number of the default network interface. Packets with destination IP addresses that don't lie in the subnet of an attached interface are sent through the default interface. Default value is 0. |
HostName | Char[] |
A zero-terminated character string of 64 bytes or less containing the host name of this machine. This setting is not actually used by the stack. It's present mainly for informative purposes and to support the gethostname /sethostname sockets API calls. To clear the host name, call NetLibIFSettingSet with a valueLen of 0.
|
DomainName | Char[] |
A zero-terminated character string of 256 bytes or less containing the default domain. This default domain name is appended to all host names before name lookups are performed. If the name is not found, the host name is looked up again without appending the domain name to it. To have the stack not use the domain name, call NetLibIFSettingSet with a valueLen of 0.
|
HostTbl | Char[] |
A null-terminated character string containing the host table. This table is consulted first before sending a DNS query to the DNS server(s). To have the stack not use a host table, call NetLibIFSettingSet with a valueLen of 0. The format of a host table is a series of lines separated by `\n' in the following format:
|
CloseWaitTime | UInt32 |
The close-wait time in milliseconds. This setting must be specified. See the discussion of the NetLibClose call for an explanation of the close-wait time.
|
TraceBits | UInt32 |
A bitfield of various trace bits. See "Tracing Bits." Default value is (netTracingErrors | netTracingAppMsgs ). An application can get a list of events in the trace buffer using the NetLibMaster call.
|
TraceSize | UInt32 | Maximum trace buffer size in bytes. Setting this setting always clears the existing trace buffer. Default is 2 KB. |
TraceRoll | UInt8 |
Boolean value, default is true (non-zero). If true , trace buffer will roll over when it fills. If false , tracing will stop as soon as trace buffer fills.
|
NetLibSettingSet
,
NetLibIFSettingSet
,
NetLibIFSettingGet
,
NetLibMaster
Err NetLibSettingSet (UInt16 libRefnum, UInt16 setting, void* valueP, UInt16 valueLen)
  |
-> |
Reference number of the net library. |
  |
-> |
Setting to set; one of the NetSettingEnum constants. See Table 54.2. |
  |
-> |
New value for the setting. |
  |
-> |
Size of new setting. |
  |
0 |
Success. |
  |
|
Invalid setting constant. |
  |
|
valueLen was invalid for the given setting. |
  |
|
valueP was too small to hold entire setting. Setting value was truncated to fit in valueP . |
  |
|
|
  |
|
|
valueP
), the size of the buffer (valueLen
), and the setting ID (setting
). The setting ID is one of the netSettingXXX
constants in the NetSettingEnum
type.
NetLibSettingGet
for an explanation of each of the settings.
netSettingResetAll
setting, which, if used, will reset all general settings to their default values. When using this setting, valueP
and valueLen
are ignored.
NetLibSettingGet
,
NetLibSettingSet
,
NetLibIFSettingSet
,
NetLibMaster
Int16 NetLibSocketAccept (UInt16 libRefnum, NetSocketRef socket, NetSocketAddrType* sockAddrP, Int16* addrLenP, Int32 timeout, Err* errP)
  |
-> |
Reference number of the net library. |
  |
-> |
Descriptor for the open socket. |
  |
<- |
Address of remote host is returned here. |
  |
<-> |
On entry, length of sockAddrP buffer in bytes. On exit, length of returned address stored in *sockAddrP . |
  |
-> |
Maximum timeout in system ticks; -1 means wait forever. |
  |
<- |
Contains an error code if the return value is -1. |
NetSocketRef
of the new socket. If the return value is -1, an error has occurred, and errP
contains one of the following values:
  |
0 |
No error. |
  |
|
Call timed out. |
  |
|
The referenced net library has not been opened yet. |
netErrParamErr
netErrSocketNotOpen
netErrSocketNotConnected
netErrSocketClosedByRemote
netErrWrongSocketType
netErrSocketNotListening
netErrUnimplemented
int accept (int socket, void* sockAddrP, int* addrLenP);
NetLibSocketAccept
on a socket, a server application needs to:
NetLibSocketOpen
).
NetLibSocketBind
).
NetLibSocketListen
). NetLibSocketAccept
will block until a successful connection request is obtained from a remote client. After a successful connection is made, this call returns with the address of the remote host in *sockAddrP
and the socket descriptor of a new socket as the return value. You then use the new socket to send and receive data.
NetLibSocketBind
,
NetLibSocketListen
Int16 NetLibSocketAddr (UInt16 libRefnum, NetSocketRef socketRef, NetSocketAddrType* locAddrP, Int16* locAddrLenP, NetSocketAddrType* remAddrP, Int16* remAddrLenP, Int32 timeout, Err* errP)
  |
-> |
Reference number of the net library. |
  |
-> |
Descriptor for the open socket. |
  |
<- |
Local address of socket is returned here. |
  |
<-> |
On entry, length of locAddrP buffer in bytes. On exit, length of returned address stored in *locAddrP . |
  |
<- |
Address of remote host is returned here. |
  |
<-> |
On entry, length of remAddrP buffer in bytes. On exit, length of returned address stored in *remAddrP . |
  |
-> |
Maximum timeout in system ticks; -1 means wait forever. |
  |
<- |
Contains an error code if the return value is -1. |
errP
contains one of the following values:
  |
0 |
No error. |
  |
|
Call timed out. |
  |
|
The referenced net library has not been opened yet. |
netErrParamErr
netErrSocketNotOpen
netErrSocketClosedByRemote
netErrOutOfCmdBlocks
int getpeername (int s, struct sockaddr* name, int* namelen);
int getsockname (int s, struct sockaddr* name, int* namelen);
NetLibSocketBind
,
NetLibSocketConnect
,
NetLibSocketAccept
Int16 NetLibSocketBind (UInt16 libRefnum, NetSocketRef socket, NetSocketAddrType* sockAddrP, Int16 addrLen, Int32 timeout, Err* errP)
  |
-> |
Reference number of the net library. |
  |
-> |
Descriptor for the open socket. |
  |
-> |
Pointer to the address to give to the socket. This can be a NetSocketAddrINType or a NetSocketAddrRawType . |
  |
-> |
Length of address in *sockAddrP . |
  |
-> |
Maximum timeout in system ticks; -1 means wait forever. |
  |
<- |
Contains an error code if the return value is -1. |
errP
contains one of the following values:
  |
0 |
No error. |
  |
|
Call timed out. |
  |
|
The referenced net library has not been opened yet. |
netErrParamErr
netErrSocketNotOpen
netErrSocketAlreadyConnected
netErrSocketClosedByRemote
netErrOutOfCmdBlocks
int bind (int socket, const void* sockAddrP, int addrLen);
NetLibSocketBind
, applications can call
NetLibSocketListen
and then
NetLibSocketAccept
to make the socket ready to accept connection requests.
NetLibSocketOpen
for instructions on how to bind raw sockets.
NetLibSocketConnect
,
NetLibSocketListen
,
NetLibSocketAccept
Int16 NetLibSocketClose (UInt16 libRefnum, NetSocketRef socket, Int32 timeout, Err* errP)
  |
-> |
Reference number of the net library. |
  |
-> |
Descriptor for the open socket. |
  |
-> |
Maximum timeout in system ticks; -1 means wait forever. |
  |
<- |
Contains an error code if the return value is -1. |
int close(int socket);
NetLibSocketOpen
,
NetLibSocketShutdown
Int16 NetLibSocketConnect (UInt16 libRefnum, NetSocketRef socket, NetSocketAddrType* sockAddrP, Int16 addrLen, Int32 timeout, Err* errP)
  |
-> |
Reference number of the net library. |
  |
-> |
Descriptor for the open socket. |
  |
-> |
Pointer to address to connect to. |
  |
-> |
Length of address in *sockAddrP. |
  |
-> |
Maximum timeout in system ticks; -1 means wait forever. |
  |
<- |
Contains an error code if the return value is -1. |
errP
contains one of the following values:
  |
0 |
No error. |
  |
|
Call timed out. |
  |
|
The referenced net library has not been opened yet. |
netErrParamErr
netErrSocketNotOpen
netErrSocketBusy
  |
|
Incorrect setup. |
netErrPortInUse
netErrQuietTimeNotElapsed
netErrInternal
netErrSocketAlreadyConnected
netErrSocketClosedByRemote
netErrTooManyTCPConnections
netErrWouldBlock
netErrWrongSocketType
netErrOutOfCmdBlocks
int connect (int socket, const void* sockAddrP, int addrLen);
NetLibSocketBind
,
NetUTCPOpen
Int16 NetLibSocketListen (UInt16 libRefnum, NetSocketRef socket, UInt16 queueLen, Int32 timeout, Err* errP)
  |
-> |
Reference number of the net library. |
  |
-> |
Descriptor for the open socket. |
  |
-> |
Maximum number of pending connections allowed. |
  |
-> |
Maximum timeout in system ticks; -1 means wait forever. |
  |
<- |
Contains an error code if the return value is -1. |
errP
contains one of the following values:
  |
0 |
No error. |
  |
|
Call timed out. |
  |
|
The referenced net library has not been opened yet. |
netErrParamErr
netErrOutOfResources
netErrSocketNotOpen
netErrSocketBusy
  |
|
Incorrect setup. |
netErrPortInUse
netErrInternal
netErrSocketAlreadyConnected
netErrSocketClosedByRemote
netErrWrongSocketType
netErrQuietTimeNotElapsed
netErrOutOfCmdBlocks
int listen (int socket, int queueLen);
NetLibSocketBind
, a server application can call NetLibSocketListen
and then
NetLibSocketAccept
to accept connections from remote clients.
queueLen
is currently quietly limited to 1 (higher values are ignored).
NetLibSocketBind
,
NetLibSocketAccept
NetSocketRef NetLibSocketOpen (UInt16 libRefnum, NetSocketAddrEnum domain, NetSocketTypeEnum type, Int16 protocol, Int32 timeout, Err* errP)
  |
-> |
Reference number of the net library. |
  |
-> |
Address domain. See NetSocketAddrEnum . |
  |
-> |
Desired type of connection. See NetSocketTypeEnum . |
  |
-> |
Protocol to use. This parameter is currently ignored. |
  |
|
For raw sockets in the netSocketAddrINET domain, specify one of the following: |
  |
|
|
  |
|
|
  |
|
|
  |
|
For all other socket types or for raw sockets in the raw domain, this parameter is ignored. |
  |
-> |
Maximum timeout in system ticks; -1 means wait forever. |
  |
<- |
Contains an error code if the return value is -1. |
NetSocketRef
of the opened socket or -1 if an error occurred. If an error occurred, errP
contains one of the following values:
  |
0 |
No error. |
  |
|
Call timed out. |
  |
|
The referenced net library has not been opened yet. |
netErrParamErr
netErrNoMoreSockets
netErrOutOfCmdBlocks
netErrOutOfMemory
int socket(int domain, int type, int protocol);
netSocketAddrINET
domain
NetLibSocketBind
, passing a
NetSocketAddrINType
structure for the socket address. The port field is ignored.
netSocketAddrRaw
domain with no protocol
NetLibSocketBind
, passing a
NetSocketAddrRawType
structure for the socket address. The instance and creator specify which interface the caller wants to receive raw packets from.
NetLibSocketClose
,
NetUTCPOpen
Int16 NetLibSocketOptionGet (UInt16 libRefnum, NetSocketRef socket, UInt16 level, UInt16 option, void* optValueP, UInt16 * optValueLenP, Int32 timeout, Err* errP)
  |
-> |
Reference number of the net library. |
  |
-> |
Descriptor for the open socket. |
  |
-> |
Level of the option, one of the NetSocketOptLevelEnum constants. See NetLibSocketOptionSet . |
  |
-> |
One of the NetSocketOptEnum constants. See NetLibSocketOptionSet . |
  |
<- |
Pointer to variable holding new value of option. |
  |
<-> |
Size of variable pointed to by optValueP on entry. Actual size of return value on exit. |
  |
-> |
Maximum timeout in system ticks; -1 means wait forever. |
  |
<- |
Contains an error code if the return value is -1. |
errP
contains one of the following values:
  |
0 |
No error. |
  |
|
Call timed out. |
  |
|
The referenced net library has not been opened yet. |
netErrParamErr
netErrSocketNotOpen
netErrUnimplemented
netErrWrongSocketType
netErrInvalidSettingSize
int getsockopt (int socket, int level, int option, const void* optValueP, int* optValueLenP);
optValueP
) and the size of this variable (in *optValueLenP
). On exit, *optValueP
is updated with the actual size of the return value.
netSocketOptIPOptions
), *optValueLenP
is unmodified on exit and this call does its best to return the value in the caller's desired type size.
*optValueLenP
parameter. If the desired type for an option is FLAG
, this call supports an *optValueLenP
of 1, 2, or 4. If the desired type for an option is int
, it supports an *optValueLenP
of 2 or 4.
NetLibSocketOptionSet
for a list of available options.
NetLibSocketOptionSet
Int16 NetLibSocketOptionSet (UInt16 libRefnum, NetSocketRef socket, UInt16 level, UInt16 option, void* optValueP, UInt16 optValueLen, Int32 timeout, Err* errP)
  |
-> |
Reference number of the net library. |
  |
-> |
Descriptor for the open socket. |
  |
-> |
Level of the option, one of the NetSocketOptLevelEnum constants. See the comments section. |
  |
-> |
One of the NetSocketOptEnum constants. See the comments section. |
  |
-> |
Pointer to the variable holding the new value of the option. |
  |
-> |
Size of variable pointed to by optValueP. |
  |
-> |
Maximum timeout in system ticks; -1 means wait forever. |
  |
<- |
Contains an error code if the return value is -1. |
errP
contains one of the following values:
  |
0 |
No error. |
  |
|
Call timed out. |
  |
|
The referenced net library has not been opened yet. |
netErrParamErr
netErrSocketNotOpen
netErrUnimplemented
netErrWrongSocketType
netErrInvalidSettingSize
int setsockopt (int socketRef, int level, int option, const void* optValueP, int optValueLen);
optValueP
and the size of the option in optValueLen
.
netSocketOptLevelXXX
constants. netSocketOptXXX
constants.
NetLibSocketOptionGet
call (G) and/or set (S) with this call.
netSocket OptLevel... |
netSocketOpt... |
G/S |
Type |
I |
Description |
---|---|---|---|---|---|
IP | IPOptions | GS | UInt8[] | N | Options in IP Header |
TCP | TCPNoDelay | GS | FLAG | Y | Don't delay send to coalesce packets |
TCP | TCPMaxSeg | G | int | Y | Get TCP maximum segment size |
Socket | SockDebug | GS | FLAG | N | Turn on recording of debug info |
Socket | SockAcceptConn | G | FLAG | N | Socket has had listen |
Socket | SockReuseAddr | GS | FLAG | N | Allow local address reuse |
Socket | SockKeepAlive | GS | FLAG | Y | Keep connections alive |
Socket | SockDontRoute | GS | FLAG | N | Just use interface addresses |
Socket | SockBroadcast | GS | FLAG | N | Permit sending of broadcast messages |
Socket | SockUseLoopback | GS | FLAG | N | Bypass hardware when possible |
Socket | SockLinger | GS |
NetSocket LingerType | Y |
Linger on close if data present
NetSocketLingerType is a structure with two fields: onOff (true or false ) and time (linger time in seconds).
|
Socket | SockOOBInLine | GS | FLAG | N | Leave received OOB data in-line |
Socket | SockSndBufSize | GS | int | N | Send buffer size |
Socket | SockRcvBufSize | GS | int | N | Receive buffer size |
Socket | SockSndLowWater | GS | int | N | Send low-water mark |
Socket | SockRcvLowWater | GS | int | N | Receive low-water mark |
Socket | SockSndTimeout | GS | int | N | Send timeout |
Socket | SockRcvTimeout | GS | int | N | Receive timeout |
Socket | SockErrorStatus | G | int | Y | Get error status and clear |
Socket | SockSocketType | G | int | Y | Get socket type |
Socket | SockNonBlocking | GS | FLAG | Y | Set non-blocking mode on/off |
optValueLen
parameter. If the desired type for an option is FLAG
, this call accepts an optValueLen
of 1, 2, or 4. If the desired type for an option is int
, it accepts an optValueLen
of 2 or 4.
netSocketOptSockNonBlocking
option, all options listed above have equivalents in the sockets API. The netSocketOptSockNonBlocking
option was added to this call in the net library in order to implement the functionality of the UNIX fcntl()
control call, which can be used to turn nonblocking mode on and off for sockets.
NetLibSocketOptionGet
Int16 NetLibSocketShutdown (UInt16 libRefnum, NetSocketRef socket, Int16 direction, Int32 timeout, Err* errP)
  |
-> |
Reference number of the net library. |
  |
-> |
Descriptor for the open socket. |
  |
-> |
Direction to shut down. One of the NetSocketDirEnum constants. Specifically: |
  |
|
netSocketDirInputnetSocketDirOutputnetSocketDirBoth |
  |
-> |
Maximum timeout in system ticks; -1 means wait forever. |
  |
<- |
Contains an error code if the return value is -1. |
errP
contains one of the following values:
  |
0 |
No error. |
  |
|
Call timed out. |
  |
|
The referenced net library has not been opened yet. |
netErrParamErr
netErrSocketNotOpen
netErrNoMultiPktAddr
netErrOutOfCmdBlocks
int shutdown (int socket, int direction);
netSocketDirInput
, the socket is marked as down in the receive direction and further read operations from it return a netErrSocketInputShutdown
error.
Err NetLibTracePrintF (UInt16 libRefnum, Char *formatStr, ...)
  |
-> |
Reference number of the net library. |
  |
-> |
A printf style format string. |
  |
-> ... |
Arguments to the format string. |
netErrNotOpen
if the net library has not been opened.
NetLibMaster
call. The net library's trace buffer is used to store run-time errors that the net library encounters as well as errors and messages from network interfaces and from applications that use this call.
formatStr
parameter is a printf
style format string which supports the following format specifiers:
netTracingAppMsgs
bit of the netSettingTraceBits
setting must be set using the call NetLibSettingSet(...netSettingTraceBits...)
. Otherwise, this routine will do nothing.
NetLibTracePutS
,
NetLibMaster
,
NetLibSettingSet
Err NetLibTracePutS (UInt16 libRefnum, Char *strP)
  |
-> |
Reference number of the net library. |
  |
-> |
String to store in the trace buffer. |
netErrNotOpen
if the net library has not been opened.
NetLibMaster
call. The net library's trace buffer is used to store run-time errors that the net library encounters as well as errors and messages from network interfaces and from applications that use this call.
netTracingAppMsgs
bit of the netSettingTraceBits
setting must be set using the NetLibSettingSet(...netSettingTraceBits...)
call or this routine will do nothing.
NetLibTracePrintF
,
NetLibMaster
,
NetLibSettingSet
.
NetNToHL (x)
x
in host byte order.
ntohl()
NetNToHS
,
NetHToNL
,
NetHToNS
NetNToHS (x)
x
in host byte order.
ntohs()
NetHToNL
,
NetNToHL
,
NetHToNS
  |   |