'\"macro stdmacro
.if n .pH g3n.t_sync @(#)t_sync	40.4 of 10/10/89
.\" Copyright 1989 AT&T
.nr X
.if \nX=0 .ds x} t_sync 3N "Networking Support Utilities" "\&"
.if \nX=1 .ds x} t_sync 3N "Networking Support Utilities"
.if \nX=2 .ds x} t_sync 3N "" "\&"
.if \nX=3 .ds x} t_sync "" "" "\&"
.if \nX=4 .ds x} t_sync "NS_LIB" "EXTENSION" " "
.TH \*(x}
.SH NAME
\f4t_sync\f1 \- synchronize transport library
.SH SYNOPSIS
\f4#include <tiuser.h>\f1
.PP
\f4int t_sync (int fd);\f1
.SH DESCRIPTION
For the transport endpoint specified by \f4fd\fP, \f4t_sync\fP
synchronizes the data structures managed by the transport library
with information from the underlying transport provider.
In doing so, it can convert a raw file descriptor
[obtained via \f4open\fP(2), \f4dup\fP(2), or as a result of a
\f4fork\fP(2) and \f4exec\fP(2)]
to an initialized transport endpoint, assuming that file descriptor referenced
a transport provider.
This function also allows two cooperating processes to synchronize their
interaction with a transport provider.
.PP
For example, if a process \f4forks\fP a new process and issues an
\f4exec\fP, the new process must issue a \f4t_sync\fP
to build the private library data structure associated with a
transport endpoint and to synchronize the data structure
with the relevant provider information.
.PP
It is important to remember that the transport provider treats
all users of a transport endpoint as a single user.
If multiple processes are using the same endpoint, they should
coordinate their activities so as not to violate the state of the
provider.
\f4t_sync\fP returns the current state of the provider to the user, thereby
enabling the user to verify the state before taking further action.
This coordination is only valid among cooperating processes;
it is possible that a process or an incoming event could change the
provider's state \f2after\fP a \f4t_sync\fP is issued.
.PP
If the provider is undergoing a state transition when \f4t_sync\fP
is called, the function will fail.
.P
On failure, \f4t_errno\f1 may be set to one of the following:
.TP 19
\f4[TBADF]\fP
The specified file descriptor does not refer to a transport endpoint.
.TP
\f4[TSTATECHNG]\fP
The transport provider is undergoing a state change.
.TP
\f4[TSYSERR]\fP
A system error has occurred during execution of this function.
.SH SEE ALSO
\f4dup\fP(2), \f4exec\fP(2), \f4fork\fP(2), \f4open\fP(2).
.sp .2
\f2UNIX System V Network Programmer's Guide\f1.
.SH DIAGNOSTICS
\f4t_sync\fP returns the state of the transport provider on successful
completion and -1 on failure and \f4t_errno\f1 is set to indicate the error.
The state returned may be one of the following:
.TP 19
\f4T_UNBND\fP
unbound
.TP
\f4T_IDLE\fP
idle
.TP
\f4T_OUTCON\fP
outgoing connection pending
.TP
\f4T_INCON\fP
incoming connection pending
.TP
\f4T_DATAXFER\fP
data transfer
.TP
\f4T_OUTREL\fP
outgoing orderly release (waiting for an orderly release indication)
.TP
\f4T_INREL\fP
incoming orderly release (waiting for an orderly release request)
.Ee
