Specifications

Chapter 18. TCP/IP
457
18.4.3 Programming Notes for Socket API
Socket API according to the TCP/IP is restricted by the following specifications. For the
extended function
SOCKET.FN3 given below, refer to Section 18.6, "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:
&h218) may occur indicating too many sockets created.
(Example)
main: Main program
on error goto Err.TCP Prepare for error interrupt (To Err.TCP
at the time of error occurrence)
iftype%=2 Specify spread spectrum communications
device
layermode%=2 Specify Ethernet as a link layer
call "socket.fn3" .fcTSetup iftype%, layermode%, interface%
Specify TCP/IP communications pathway
Use SOCKET.FN3 function #40
hCom3%=1 Specify a file number to be opened
open "COM3:" as #hCom3% Open spread spectrum communications
device
Use the OPEN "COM3:" statement
loop
call "socket.fn3" .fcTCnnSys interface% Connect to TCP/IP communications
pathway (system settings)
Use SOCKET.FN3 function #41
family%=2 Internet protocol
type%=1 Stream socket
protocol%=6 TCP protocol
call "socket.fn3" .fcSocket family%, type%, protocol%, sockfd%
Create TCP socket
Use SOCKET.FN3 function #26
port%=1201
call "socket.fn3" .fcConnect sockfd%, family%, port%, serv.addr$
Connect socket to server
Use SOCKET.FN3 function #3