This topic describes the steps of writing the
Pascal program.
Before you begin
To use the Pascal language API, you should have experience
in Pascal language programming and be familiar with the principles
of internetwork communication.
Procedure
Perform the following steps to write the Pascal program.
- Start TCP/UDP/IP service (BeginTcpIp).
_________________________________________________________________
- Specify the set of notifications that TCP/UDP/IP
can send you (Handle).
_________________________________________________________________
- Establish a connection (TcpOpen, UdpOpen, RawIpOpen,
and TcpWaitOpen).
Note: If using TcpOpen, communication
must wait for the appropriate notification of connection.
_________________________________________________________________
- Transfer a data buffer to or from the TCP/IP address space
(TcpSend, TcpFSend, TcpWaitSend, TcpReceive, TcpFReceive, TcpWaitReceive,
UdpSend, UdpNReceive, RawIpSend, UdpReceive, and RawIpReceive).
Notes: - TcpWaitReceive and TcpWaitSend are synchronous calls.
- TcpFSend and TcpSend are the asynchronous ways of sending data
on a TCP connection. Both procedures return to your program immediately.
TcpSend does not wait under any circumstance.
- TcpSend and TcpFSend differ in how they handle the situation when
TCP/IP address space has insufficient buffer space to accept the data
being sent.
- In the case of insufficient buffer space, TCP/IP responds to TcpSend
with the return code NObufferSPACE. This return code is sent back
to the application. It is the application's responsibility to wait
for BUFFERspaceAVAILABLE notification and resend the data.
- In the case of TcpFSend with insufficient buffer space, the PASCAL
API blocks until buffer space becomes available or an error is detected.
This is the only condition under which TcpFSend blocks.
_________________________________________________________________
- Check the status returned from TCP/IP in the
form of notifications (GetNextNote).
_________________________________________________________________
- Repeat the data transfer operations (Steps 4
and 5) until the data is exhausted.
_________________________________________________________________
- Terminate the connection (TcpClose, UdpClose, and RawIpClose).
Note: If you are using TcpClose, you must wait for the connection
to terminate.
_________________________________________________________________
- Terminate the communication service (EndTcpIp).
_________________________________________________________________
Results
You know you are done when control is returned to you.
Control is returned, in most instances, after the initiation of your
request. When appropriate, some procedures have alternative wait versions
that return only after request completion.
Example
A sample program is supplied with TCP/IP. See Sample Pascal program, for a listing of the sample program.