DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Developing applications over TCP/IP using TLI

How TLI functions behave over TCP and UDP

Be aware of the following special considerations when using TLI functions over a TCP/IP provider. The TLI functions are listed in alphabetical order.

t_accept

This function never returns any user data to the caller. Consequently, the value of call->udata.len must be set to zero.

You cannot send user options during connection establishment over TCP. Consequently, call->opt.len should be zero when calling t_accept.

TCP returns the maximum segment size negotiated during connection establishment. Consequently, the value of call->opt.len will be non-zero.

When using this function with TCP, note that TCP has already synchronized the connection. There is no concept of rejecting a pending connection with TCP.

This function can only be used with TCP. If called on a UDP endpoint, the function returns -1 and t_errno is set to TNOTSUPPORT.

t_alloc

There are no special considerations when calling this function over either TCP or UDP.

t_bind

TCP will normally disallow binding to an address/port pair if another endpoint exists that has bound to the specified address/port pair. Since TCP retains connection state for up to 4 minutes to satisfy theRFC 793 ``quiet-time'' requirement, you can disable this behavior by using t_optmgmt to enable the SO_REUSEADDR option. This will allow a new endpoint to be bound to a specified address/port pair even if a connection exists in TIME-WAIT state.

UDP will normally disallow binding to an address/port pair if another endpoint exists that has bound to the specified address/port pair. To allow delivery of multicast/broadcast datagrams to multiple application instances, you can disable this behavior by using t_optmgmt to enable the SO_REUSEPORT option. This allows multiple applications to bind to the same port. Note that this only produces the desired behavior for multicast or broadcast datagrams. Unicast datagrams will only be delivered to one process.

t_close

There are no special considerations when calling this function over either TCP or UDP.

t_connect

User data cannot be sent during establishment of a TCP connection. Therefore, sndcall->udata.len must be set to zero. This field is set correctly if t_alloc is used to allocate sndcall.

User options cannot be sent during establishment of a TCP connection. Therefore, sndcall->opt.len must be set to zero. This field is not set correctly when t_alloc is used to allocate sndcall.

TCP returns the maximum segment size negotiated during connection establishment. Consequently, the value of call->opt.len is non-zero upon return from t_connect.

This function can be used only with TCP. If called on a UDP endpoint, the function returns -1 and t_errno is set to TNOTSUPPORT.

t_error

There are no special considerations when calling this function over either TCP or UDP.

t_free

There are no special considerations when calling this function over either TCP or UDP.

t_getinfo

These fields are part of the t_info structure returned by t_getinfo when called for TCP:


addr
always contains the value of sizeof(struct sockaddr_in)

options
always contains the value of -1. This indicates that there is no length restriction on the size of options. Internally, the TLI library allocate buffers of 1024 bytes in this instance.

tsdu
always contains the value of 0. This indicates that data is sent as a byte-stream, and has no length restriction.

etsdu
always contains the value of 0. This indicates that expedited data is sent as a byte-stream, and has no length restriction.

connect
always contains the value of -2. This indicates that you cannot send user data while establishing a connection.

discon
always contains the value of -2. This indicates that you cannot send user data while releasing a connection.

flags
always has the value 0. This indicates that no special features are supported.

servtype
always has the value T_COTS_ORD. This indicates that TCP is a connection-oriented provider that supports orderly connection release.
These fields are part of the t_info structure returned by t_getinfo when called for UDP:

addr
always contains the value of sizeof(struct sockaddr_in).

options
always contains the value of -1. This indicates that there is no length restriction on the size of options. Internally, the TLI library allocate buffers of 1024 bytes in this instance.

tsdu
normally contains the value of 65507. This indicates that the largest UDP datagram that may be sent is 65535 minus the size of a combined UDP/IP header (28).

etsdu
always contains the value of -2. This indicates that you cannot send expedited data.

connect
always contains the value of -2. This indicates that you cannot send user data while establishing a connection.

discon
always contains the value of -2. This indicates that you cannot send user data while releasing a connection.

flags
always has the value 0. This indicates that no special features are supported.

servtype
always has the value T_CLTS. This indicates that UDP is a connectionless transport provider.

t_getstate

There are no special considerations when calling this function over either TCP or UDP.

t_listen

You cannot send user data during connection establishment over TCP. Consequently, call->udata.len equals zero when the function returns.

This function can only be used with TCP. If called on a UDP endpoint, the function returns -1 and t_errno is set to TNOTSUPPORT.

t_look

There are no special considerations when calling this function over TCP.

Because you cannot send expedited data over UDP, t_look never returns the events T_EXDATA and T_GOEXDATA when used over UDP.

t_open

These fields are part of the t_info structure returned by t_open when called for TCP:


addr
always contains the value of sizeof(struct sockaddr_in).

options
always contains the value of -1. This indicates that there is no length restriction on the size of options. Internally, the TLI library allocate buffers of 1024 bytes in this instance.

tsdu
always contains the value of 0. This indicates that data is sent as a byte-stream, and has no length restriction.

etsdu
always contains the value of 0. This indicates that expedited data is sent as a byte-stream, and has no length restriction.

connect
always contains the value of -2. This indicates that you cannot send user data while establishing a connection.

discon
always contains the value of -2. This indicates that you cannot send user data while releasing a connection.

flags
always has the value 0. This indicates that no special features are supported.

servtype
always has the value T_COTS_ORD. This indicates that TCP is a connection-oriented provider that supports orderly connection release.
These fields are part of the t_info structure returned by t_open when called for UDP:

addr
always contains the value of sizeof(struct sockaddr_in).

options
always contains the value of -1. This indicates that there is no length restriction on the size of options. Internally, the TLI library allocate buffers of 1024 bytes in this instance.

tsdu
normally contains the value of 65507. This indicates that the largest UDP datagram that may be sent is 65535 minus the size of a combined UDP/IP header (28).

etsdu
always contains the value of -2. This indicates that you cannot send expedited data.

connect
always contains the value of -2. This indicates that you cannot send user data while establishing a connection.

discon
always contains the value of -2. This indicates that you cannot send user data while releasing a connection.

flags
always has the value 0. This indicates that no special features are supported.

servtype
always has the value T_CLTS. This indicates that UDP is a connectionless transport provider.

t_optmgmt

When used with TLI, the T_CHECK flag also causes the current value of the option to be returned.

t_rcv

Note that TCP does not preserve record boundaries in the data stream. Therefore t_rcv is not guaranteed to return the same number of bytes as were sent by a call to t_snd. Also, this means that the T_MORE flag will never be set in flags upon return from t_rcv.

This function can only be used with TCP. If called on a UDP endpoint, the function returns -1 and t_errno is set to TNOTSUPPORT.

t_rcvconnect

User data cannot be sent during connection establishment over TCP. Consequently, call->udata.len equals zero when the function returns.

TCP returns the maximum segment size negotiated during connection establishment. Consequently, the value of call->opt.len is non-zero when t_rcvconnect returns.

This function can be used only with TCP. If called on a UDP endpoint, the function returns -1 and t_errno is set to TNOTSUPPORT.

t_rcvdis

You cannot send user data during connection release over TCP. Consequently, discon->udata.len equals zero when the function returns.

discon->reason will normally be an Internet error code defined in <sys/errno.h>.

This function can only be used with TCP. If called on a UDP endpoint, the function returns -1 and t_errno is set to TNOTSUPPORT.

t_rcvrel

There are no special considerations when calling this function over TCP.

This function can only be used with TCP. If called on a UDP endpoint, the function returns -1 and t_errno is set to TNOTSUPPORT.

t_rcvudata

There are no special considerations when calling this function over UDP.

This function can only be used with UDP. If called on a TCP endpoint, the function returns -1 and t_errno is set to TNOTSUPPORT.

t_rcvuderr

uderr->error will normally be an Internet error code defined in <sys/errno.h>.

This function can only be used with UDP. If called on a TCP endpoint, the function returns -1 and t_errno is set to TNOTSUPPORT.

t_snd

Note that TCP does not preserve record boundaries in the data stream. Therefore a subsequent t_rcv is not guaranteed to return the same number of bytes as were sent by the call to t_snd. Also, TCP does not honor the T_MORE flag.

This function can only be used with TCP. If called on a UDP endpoint, the function returns -1 and t_errno is set to TNOTSUPPORT.

t_snddis

You cannot send user data during connection release over TCP. Consequently, call->udata.buf should be set to NULL, and call->udata.len should be set to zero.

You cannot send user options during connection release over TCP. Consequently, call->opt.buf should be set to NULL, and call->opt.len should be set to zero.

This function can only be used with TCP. If called on a UDP endpoint, the function returns -1 and t_errno is set to TNOTSUPPORT.

t_sndrel

There are no special considerations when calling this function over TCP.

This function can only be used with TCP. If called on a UDP endpoint, the function returns -1 and t_errno is set to TNOTSUPPORT.

t_sndudata

There are no special considerations when calling this function over UDP.

This function can only be used with UDP. If called on a TCP endpoint, the function returns -1 and t_errno is set to TNOTSUPPORT.

t_sync

There are no special considerations when calling this function over either TCP or UDP.

t_unbind

There are no special considerations when calling this function over either TCP or UDP.


Next topic: Annotated code sample
Previous topic: Example

© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003