Download ACS CFSound-IV BASIC Programming

Transcript
ACS CFSound-IV BASIC Programming Manual
1 October 2015
Server Blocking Listen
The synchronous socket server listen takes the form:
SOCKET.SYNC.LISTEN(#N, “:port”, connect( ), recv( ), send( ))
#N
“:port”
connect( )
recv( )
send( )
File number
String representation of TCP/IP port number
User function called when connection occurs
User function called to receive data from ‘file’ #N
User function called to send data to ‘file’ #N
The SOCKET.SYNC.LISTEN( ) function opens a TCP/IP port as file #N using the “:port” string.

When a remote client establishes a connection to the listening port the user provided connect( )
function is called.

When this function returns, the user provided recv( ) function is called to input data from the
remote device using INPUT #N or FINPUT #N statements. The recv( ) function should return one
to send more data, two to receive more data or zero to disconnect.

Next the user provided send( ) function is called to output data to the remote device using PRINT
#N or FPRINT #N statements. The send( ) function should return one to wait for received data,
two to send more data or zero to disconnect.
The process repeats between recv( ) and send( ) calls until one of the functions returns zero or an error
condition occurs. The SOCKET.SYNC.LISTEN( ) function then returns a numeric value representing the
“result” of the connection:
SOCKET.SYNC.LISTEN( )
returns
0
1
2
3
4
5
Description
Unknown / No Status
Disconnect / Done / No Error
Open Error – requested file #N failed to open
Connection Timeout – no connection within the
@SOCKET.TIMEOUT interval
Data Send Timeout – no send data acknowledgment within the
@SOCKET.TIMEOUT interval
Receive Data Timeout – no received data within the
@SOCKET.TIMEOUT interval
Non-blocking Sockets
Asynchronous or non-blocking sockets are implemented using a statement to ‘start’ the communication,
user functions to control the order and flow of data and a system variable to return the “result” of the
connection. The user defined functions are called in-between other program statements that are executing to
provide control points during the socket operation. There are two statements to ‘start’ the asynchronous
socket communication.
Client Non-blocking Connection
The asynchronous client connection is started using the following program statement:
SOCKET.ASYNC.CONNECT #N, “ip:port”, connect( ), send( ), recv( )
#N
“ip:port”
connect( )
send( )
recv( )
File number
String representation of IPv4 address and TCP/IP port number
User function called when connection occurs
User function called to send data to ‘file’ #N
User function called to receive data from ‘file’ #N
Copyright©1992-2015 by ACS, Sarasota, Florida
121
Back to Table of Contents
ALL RIGHTS RESERVED