Specifications

Chapter 18. TCP/IP
441
18.2.4 Sample Program
main: Main program
on error goto Err.TCP Prepare for error interrupt (To Err.TCP
at the time of error occurrence)
.
.
.
open "COM3:" as #hCom3% Open a spread spectrum communications device
.
.
.
Use the OPEN "COM3:" statement
sock.stts% = 1 Set "1" to socket processing number
.
.
.
call "socket.fn3" .fcTCnnSys interface% Connect TCP/IP communications pathway
(system settings)
.
.
.
Use SOCKET.FN3 function #41
sock.stts% = 2 Set "2" to socket processing number
.
.
.
call "socket.fn3" .fcSocket family%,type%,protocol%,sockfd% Generate socket
.
.
.
Use SOCKET.FN3 function #26
sock.stts% = 3 Set "3" to socket processing number
.
.
.
call "socket.fn3" .fcConnect sockfd%,family%,port%,serv.addr$ Connect socket
.
.
.
Use SOCKET.FN3 function #3
sock.stts% = 4 Set "4" to socket processing number
.
.
.
.
.
.
return
Err.TCP: Error interrupt processing
Control transferred to this step if an
error occurs
err.code% = ERR Get error number
err.line% = ERL Get error line number
resume Sock.Err RESUME statement to transfer control from
error interrupt processing to socket error
processing routine
Sock.Err: Socket error processing routine
print " ERR : " ; hex$( err.code% ) Display error number
print " ERL : " ; hex$( err.line% ) Display error line number
if sock.stts% >= 3 then If OK until socket generation,
call "socket.fn3" .fcClose sockfd% close the socket
endif
if sock.stts% >= 2 then If OK until connection of TCP/IP
communications pathway
call "socket.fn3" .fcTDiscnn interface% disconnect the pathway
endif
if sock.stts% >= 1 then If OK until opening the spread spectrum
communications device,
close #hCom3% close the device
endif
goto main To main program