Sequence of TLI functions for SPX
Applications that use SPX can be either
server applications or client applications.
The application type determines the sequence and the
types of TLI calls made to access SPX.
Server applications need to:
-
open a transport endpoint
-
listen for client connections
-
service client requests
Client applications need to:
-
open a transport endpoint
-
establish a connection with a server
-
request and receive information from the server
Procedures for both server and client
applications are presented below.
Server application calling sequence
A synchronous server application must:
-
Open the SPX driver (/dev/nspx)
using the t_open call.
The t_open call
returns a file descriptor (fd).
-
Bind fd to a well-known socket number
that client connection requests will arrive on
using the t_bind call.
-
Obtain a second file descriptor (fd2)
using the t_open call with the device
set to the SPX driver
(/dev/nspx).
-
Bind fd2 to a dynamic socket number
using the t_bind call.
-
Listen for incoming connection requests using
the t_listen call.
-
Fork a child upon receiving a connection request.
-
The parent should close fd2 and return to step 3.
The parent continues looping through steps 3 to 7
until the parent exits (skip to step 14).
The forked child performs steps 8 through 13.
-
The forked child issues a t_accept
to accept the connection request using
t_accept(fd, fd2, call).
-
The forked child should close
fd with t_close.
-
The forked child uses t_snd or
t_rcv to send or receive data on fd2.
-
The forked child listens for or sends a disconnection
indication using t_rcvdis or t_snddis.
-
On exiting, the forked child unbinds fd2
using a t_unbind call.
-
On exiting, the forked child closes fd2
using a t_close call.
-
On exiting, the parent unbinds fd
using a t_unbind call.
-
On exiting, the parent closes fd
using a t_close call.
Client application calling sequence
A synchronous client
application must:
-
Open the SPX driver (/dev/nspx)
using the t_open call.
The t_open call
returns a file descriptor (fd).
-
Obtain the address of the server to which to connect.
The method for obtaining the address is up to the client application.
``IPX addresses''
describes procedures for obtaining addresses.
-
Bind to a static or dynamic socket using a
t_bind call.
-
Send a connection request to the server using
a t_connect call.
-
Use t_snd to send or t_rcv
to receive data on fd.
-
Listen for or send a disconnection request.
Use t_rcvdis to receive a
disconnect request or t_snddis
to send a disconnect request.
-
On exiting, use the t_unbind call
to close the file descriptor obtained in step 1.
-
On exiting, use the t_close
call to close the file descriptor obtained in step 1.
Next topic:
SPX driver characteristics
Previous topic:
Using the SPX protocol
© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003