448
18.3.4
Sample Program
Given below is a sample program that shows only the skeleton of communication program and
requires modification in actual programming as necessary.
’****************************************
’ Data Section *
’****************************************
DIM RECVBUFF$[255]
’Receive data buffer
DIM SENDBUFF$[255]
’Send data buffer
DIM IPADDRESS$[15]
’IP address
DIM R.SOCKSET$[41]
’Read socket ID set
DIM W.SOCKSET$[41]
’Write socket ID set
DIM E.SOCKSET$[41]
’Exception socket ID set
’************************************************
’ Sample subroutine for TCP client *
’************************************************
TCPCLIENT:
’Create send data
FOR I%=0 TO 254 STEP 1
SENDBUFF$[I%] = CHR$(I%)
NEXT I%
TCP.STTS% = 0
ON ERROR GOTO 0
’Disable error trapping
ON ERROR GOTO TCP.ERR
’Enable error trapping
’Set TCP/IP parameters
IFTYPE% = 0
’Specify COM1
LAYERMODE% = 2
’Specify Ethernet
CALL "SOCKET.FN3" .fcTSetup IFTYPE%, LAYERMODE%, INTERFACE%
’Open IrDA communications device
TCP.OPEN:
OPEN "COM1:115200" AS #1
’Open COM1
TCP.STTS% = 1
’Connect to TCP/IP communications pathway (with user settings)
CALL "SOCKET.FN3" .fcTCnnUsr INTERFACE%, MY.ADDR$, SUBNETMASK$, GATEWAY$
TCP.STTS% = 2
’Create TCP socket <-----Equivalent to BSD4.4 socket API () function
FAMILY% = 2
’Internet protocol
TYPE% = 1
’Stream socket
PROTOCOL% = 6
’TCP protocol
CALL "SOCKET.FN3" .fcSocket FAMILY%, TYPE%, PROTOCOL%, SOCKFD%
Summary of Contents for BHT-BASIC 100 SERIES
Page 1: ......
Page 161: ...153 Chapter 10 Sleep Function CONTENTS 10 1 Sleep Function 154...
Page 163: ...155 Chapter 11 Resume Function CONTENTS 11 1 Resume Function 156...
Page 173: ...165 Chapter 13 Backlight Function CONTENTS 13 1 Backlight Function 166...
Page 249: ...241 Example CLOSE IF kyIn Y THEN KILL Master Dat END IF Reference Statements CLFILE...