Chapter 17. TCP/IP
369
17.3.2 Programming Notes for Socket API
[ 1 ] Programming Notes for TCP
(a) Avoid retransmission control in application programs (recommended)
The TCP has flow control and retransmission control, so incorporating retransmission
control into communication programs using the TCP socket may cause send data to be
double sent or unintended data to be received.
When using the TCP socket, therefore, do not incorporate retransmission control in
applications.
If an error occurs in TCP socket communication, close the socket once, then open it and
start communication from the beginning again.
(b) Modify the status retaining period (recommended)
Socket API according to the TCP/IP is restricted by the following specifications. For the
extended function SOCKET.FN3 given below, refer to Section 17.5 "Socket Library
(SOCKET.FN3)."
(1) After closed, the TCP socket will retain data for 60 seconds to keep the current status.
For the 60 seconds, therefore, the socket cannot be used again.
(2) SOCKET.FN3 function #26 may create a maximum of 64 sockets.
(3) The TCP/IP will function from when SOCKET.FN3 function #41 or #42 connects the
TCP/IP communications pathway until SOCKET.FN3 function #43 disconnects it.
Except for this period, timers used in the TCP/IP will stop.
In programming for TCP socket communication, if the period from connection to
disconnection of the TCP/IP communications pathway is too short (approx. 1 second),
then an error may occur. In the sample below, when the 65th socket is created, a run-time
error (error code: &h218h) may occur indicating too many sockets created.
To avoid occurrence of run-time errors, set socket options (SOCKET.FN3 function #24)
following TCP socket creation (SOCKET.FN3 function #26).
optname%=29 'Set status retaining period after
option%=0 'closing TCP socket to 0 second
'(release immediately)
call "socket.fn3" .fcSSckOpt sockfd%, optname%, option
'Set socket options
'Use SOCKET.FN3 function #24.
Kommentare zu diesen Handbüchern