User Tools

Site Tools


tcp_template_support.htm
Navigation:  Language Reference > TCP/IP  Client/Server communications >TCP/IP Socket Communications - Template support Previous pageReturn to chapter overviewNext page

The TCP/IP Socket Communication support makes it simple to implement a Socket Server and Client.  The template support allows you to easily send messages or data, or user-defined notifications to a single recipient, or broadcast to all connected clients.

There are two Extension Templates, and several Code templates that do all the work.

To get started Register the ClaSocket.tpl

SocketTemplates

Extension Templates

Global Extension

To use the socket support add the Socket Communication Support - Global extension

SocketGlobal

Procedure Extension

On any Procedure that you want to use the Socket Code templates or the QuickAppConnectClass, add the Socket Communication Support Procedure extension template

SocketProcExt

Client Tab

Client Tab

PROMPT Value
Disable Support for Sockets Toggle the checkbox to disable the sockets support
Implement Server? Toggle the checkbox to enable Server functionality(You need one Executable to act as a Server)
Implement Client? Toggle the checkbox to enable Client functionality(a Server can implement both Client and Server)
Server IP Specify a variable which contains the Server IP number
Server Port Specify a variable which contains the Server Port
Server Name Specify a variable which contains  the Server Name
Get IP and Name at Runtime Toggle this checkbox so that the Machine name and IP number are retrieved at runtime
Variable to store error Specify a variable to store a Numeric error code
On Action Failed Specify code to execute if the action fails with an error (can be a Procedure or a Routine)
On Action Succeeds Specify code to execute if the action succeeds (can be a Procedure or a Routine)
When not connected Specify code to execute if the action can't be executed because the Client is not connected (can be a Procedure or a Routine)
Client Tab
Use Server settings? Toggle the checkbox to use the same settings as specified on the Server Tab
Server IP Specify a variable which contains the Server IP number
Server Port Specify a variable which contains the Server IP number
Server Name Specify a variable which contains  the Server Name
Server Password Specify the variable used to store the password to the server (if you are using one)

Code Templates

The Code templates provide support for the following Socket “Actions”:

·Connect to Server

·Disconnect from Server

·Start Server

·Stop Server

·Initialize IP and Name

·Send Message

·Send Notification

·Broadcast Notification

·Broadcast Shutdown


Execute Socket Action - Connect/Disconnect

(used to connect or disconnect from the server)

SocketsConnDisCon

The “Execute Socket Action - Connect/Disconnect” code template is used to either connect or disconnect from the server.

If the Action is to connect to the server then he template generates the routine:

QuickAppConnect_ConnectToServer     ROUTINE

If the Action is to disconnect from the server then he template generates the routine:

QuickAppConnect_DisconnectFromServer ROUTINE

Add your custom code in the Embed tree under Procedure Routines

SocketoutinesConnDiscon


Execute Socket Action - Server

(used to start or stop the Server listening on the designated Port, or to initialize the IP number and Name as returned by the OS)

SocketsServerStart2

SocketsServerStart

If the Action is set to “Start Server” the templates generate the Routine:

QuickAppConnect_StartServer         ROUTINE

If the Action is set to “Stop Server” the templates generate the Routine:

QuickAppConnect_StopServer         ROUTINE

Or add your custom code in the Embed tree:

SocketsEmbedServer

If the Action is set to “Initialize IP and Name” the templates generate the Routine

QuickAppConnect_InitializeServerInfo ROUTINE

Or add your custom code in the Embed tree:

SocketsIPandName


Related code templates:

Send Notification

Broadcast Notification

Broadcast Shutdown

Execute Socket Action - Message

(used to send a STRING or GROUP to the server to be relayed to a single specified computer)

SocketSendMessage

Prompt Value
Action To send any STRING or GROUP set the Action to “Send Message”
Message Content Select a variable that contains the data you want to send
User Recipient Select a variable that has the recipient name(The name used to login to the server)
Disable Error Message Optionally you can choose not to execute any error handling code that is specified on the Procedure extension
Disable Not Conneced Message Optionally you can choose not to execute any error handling code when the connection is not established (specified on the Procedure extension)
Disable Action Succeeded Optionally you can choose not to execute any “On Success” code that is specified on the Procedure extension

When the Socket action is set to “Send Message” the templates generate the Routine

QuickAppConnect_ExecuteAction_Message_9 ROUTINE

Or add your custom code in the Embed tree under Procedure Routines

SocketRoutinesSendMessage

The computer that receives the Message executes the Event_Message method

QuickAppConnect.Event_Message PROCEDURE(STRING pFromUserName,STRING pToUserName,STRING pMsgText)


Related code templates:

Send Message

Send Notification

Broadcast Notification

Broadcast Shutdown

Execute Socket Action - Notify

(used to send a User-Defined numeric code and a STRING or GROUP to the server to be relayed to a single specified computer)

SocketsSendNotify

Prompt Value
Action To send any STRING or GROUP along with a User-Defined numeric code that tells the recipient something about the dataset the Action to “Send Notification”
Message Content Select a variable that contains the data you want to send
Notification Code Select a variable that will hold the User-Defined code that tells the recipient about the data or action being relayed
User Recipient Select a variable that has the recipient name(The name used to login to the server)
Disable Error Message Optionally you can choose not to execute any error handling code that is specified on the Procedure extension
Disable Not Connected Message Optionally you can choose not to execute any error handling code when the connection is not established (specified on the Procedure extension)
Disable Action Succeeded Optionally you can choose not to execute any “On Success” code that is specified on the Procedure extension

When the Socket action is set to “Send Notification” the templates generate the Routine:

QuickAppConnect_ExecuteAction_Notify_7 ROUTINE

Or add your custom code in the Embed tree under Procedure Routines

SocketsEmbedsNotify

The computer that receives the Notification executes the Event_Notification method:

QuickAppConnect.Event_Notification PROCEDURE(STRING pFromUserName,STRING pToUserName,LONG pNotificationCode,STRING pMsgText)


Related code templates:

Send Message

Send Notification

Broadcast Notification

Broadcast Shutdown

Execute Socket Action - BroadcastNotification

(used to send a User-Defined numeric code and a STRING or GROUP to the server to be relayed to all connected clients)

SocketsBroadNotify

Prompt Value
Action To send any STRING or GROUP along with a User-Defined numeric code that tells the recipients something about the dataset the Action to “Broadcast Notification”
Message Content Select a variable that contains the data you want to send
Notification Code Select a variable that will hold the User-Defined code that tells the recipient about the data or action being relayed
Disable Error Message Optionally you can choose not to execute any error handling code that is specified on the Procedure extension
Disable Not Connected Message Optionally you can choose not to execute any error handling code when the connection is not established (specified on the Procedure extension)
Disable Action Succeeded Optionally you can choose not to execute any “On Success” code that is specified on the Procedure extension

When the Socket action is set to “Broadcast Notification” the templates generate the Routine:

QuickAppConnect_ExecuteAction_BroadcastNotification_5 ROUTINE

Or add your custom code in the Embed tree under Procedure Routines

SocketsEmbedsBrNotify

The computers that receive the Broadcast Notification execute the Event_BroadcastNotification method:

QuickAppConnect.Event_BroadcastNotification PROCEDURE(STRING pFromUserName,LONG pNotificationCode,STRING pMsgText)


Related code templates:

Send Message

Send Notification

Broadcast Notification

Broadcast Shutdown

Execute Socket Action - BroadcastShutdown

(used to send a User-Defined numeric code and a STRING or GROUP to the server to be relayed to all connected clients)

SocketsBroadShut

Prompt Value
Action To send any STRING or GROUP along with a User-Defined numeric code that tells the recipients something about the dataset the Action to “Broadcast Shutdown”
Message Content Select a variable that contains the data you want to send
Notification Code Select a variable that will hold the User-Defined code that tells the recipient about the data or action being relayed
Disable Error Message Optionally you can choose not to execute any error handling code that is specified on the Procedure extension
Disable Not Connected Message Optionally you can choose not to execute any error handling code when the connection is not established (specified on the Procedure extension)
Disable Action Succeeded Optionally you can choose not to execute any “On Success” code that is specified on the Procedure extension

When the Socket action is set to “Broadcast Shutdown” the templates generate the Routine:

QuickAppConnect_ExecuteAction_Shutdown_6 ROUTINE

Or add your custom code in the Embed tree under Procedure Routines

SocketsEmbedsBrShut

The computers that receive the Broadcast Notification execute the Event_BroadcastShutdown method:

QuickAppConnect.Event_BroadcastShutdown PROCEDURE(STRING pFromUserName,LONG pNotificationCode,STRING pMsgText)


Example Usage:

See …\Examples\QuickSock\QuickChat.app

See also:

TCP Client/Server Communications

TCP Template Support

QuickAppConnectClass

tcp_template_support.htm.txt · Last modified: 2021/04/15 15:57 by 127.0.0.1