
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%
Содержание BHT-BASIC 100 SERIES
Страница 1: ......
Страница 161: ...153 Chapter 10 Sleep Function CONTENTS 10 1 Sleep Function 154...
Страница 163: ...155 Chapter 11 Resume Function CONTENTS 11 1 Resume Function 156...
Страница 173: ...165 Chapter 13 Backlight Function CONTENTS 13 1 Backlight Function 166...
Страница 192: ...Chapter 14 Statement Reference 184 Example OPEN master Dat AS 1 FIELD 1 20 AS bar 10 AS ky CLFILE 1 CLOSE 1...
Страница 249: ...241 Example CLOSE IF kyIn Y THEN KILL Master Dat END IF Reference Statements CLFILE...
Страница 349: ...341 Run time errors Error code Meaning 05h Parameter out of the range checktype is out of the range...
Страница 383: ...375 Run time errors Reference Error code Meaning 05h Parameter out of the range Functions LEFT LEN and RIGHT...