Connecting to a network connection part
The Connection part's actions and events enable a VA Smalltalk application to perform all of the basic tasks involved in communicating with a remote server:
By making connections to the actions and events of a Connection part, you can create sequences of behavior that perform network functions in the order required by your application.
For example, you can use the connected attribute to trigger the sendString action; this causes the Connection part to send the data immediately after the network connection is made. Likewise, you can connect the sent event to the receive action, which causes the Connection part to wait for incoming data as soon as it has finished sending.
Connecting to a server
To connect to a remote server, make a connection to the connect action of the Connection part.
The connect action requires a parameter, spec, which represents the Connection Spec part that identifies the remote server and the protocol-specific communication parameters.
To supply the Connection Spec, connect the self attribute of a Connection Spec part to the spec attribute of the connection that triggers the connect action.
The connected event of the Connection part indicates that the connection was successful.
Sending data to the server
To send data to the remote server, make a connection to the sendXxxx action of the Connection part.
Note:
Xxxx is used here to indicate any of several different send actions. For example, sendString.
The sendXxxx action requires a parameter, which represents the data you want to send.
Connect the appropriate attribute of a part that can provide the string you want to send (for example, the string attribute of a text entry field) to the string attribute of the connection that triggers the sendXxxx action.
The sent event indicates that the connection part has successfully sent data to the server.
A connection part also has other actions that send other types of data: sendBuffer, sendRecord, and sendStringAsLLAsciiZ.
Receiving data from the server
You can receive data from the server in two ways: using the result attribute or the Receive Buffer part.
To receive data from the server, you can make a connection to the receive action of the Connection part. To retrieve the received data, connect to the result attribute of the connection that triggers the receive action. For example, to display the results in a text entry field, connect the result attribute of the connection to the string attribute of the text entry field. After the receive action runs, the results appear in the entry field.
If you use the receiveBuffer action to receive data, you can connect the result of the receiveBuffer action to a Receive Buffer part. The Receive Buffer part enables you to access not only the received data buffer, but also any state data that was transmitted along with it.
The received event indicates that the Connection part has received data from the server.
Disconnect from the server
To disconnect from the remote server, make a connection to the disconnect action of the Connection part.
The disconnected event indicates that the Connection part has successfully disconnected from the server.
Last modified date: 01/29/2015