Socket
Username:  
Password:
  > Home
> User Guide
v Reference
    > Introduction
    > CROFT
    > BEE Variables
    > BEE Syntax
    v BEE Commands
       > Variable Operations
       > Conditional
       > Loop
       > Module Calling
       > Remote Calling
       > Authentication
       > Data Access
       v Socket
          o socketcreate
          o socketbind
          o socketlisten
          o socketaccept
          o socketconnect
          o socketread
          o socketwrite
          o socketclose
          o socketcontrol
       > Special Functions
    > Database Operation
    > Content Management
    > Objects and Classes
    > Interface with others
    o Glossary
> Portal Object
> Development Guide


Shortcuts
sys Class
debug Class
Intrinsic Conversions
>> Reference >> BEE Commands >> Socket <=  =>      <  1  >  
Socket

Sockets are endpoints for communication between processes or hosts.

The most common model of communication is the client-server one, in which the "server" process or host is running all the time, waiting for requests to serve, and the "client" process or host sends requests to the server and get the reply from it for further processing.

The typical live cycle of a server socket is create-bind-listen-accept-read-write-close, while that of the client is create-connect-write-read-close.  The status%socket and message%socket variables will be set accordingly after each operation.  However, in the following examples, the status and message variables are ignored for simplicity.

A Typical Server Process:

socketcreate serverSock;

socketbind serverSock address="the.server.com" port=100;

while (true) {

   socketlisten serverSock;

   socketaccept serverSock newsocket=msgSock;

   socketread msgSock;

   display "Request: {msgSock%read:content}<br> ";

   if ('{msgSock%read:content}' == 'quit') break;

   socketwrite msgSock content="I heard: {msgSock%read:content}";

   socketclose msgSock;

}

socketclose serverSock;

 

 

A Typical Client Process:

socketcreate clientSock;

socketconnect clientSock address="the.server.com" port=100;

socketwrite clientSock content="hello world";

socketread clientSock;

display "Reply: {clientSock%read:content}<br> ";

socketclose clientSock;

 

 

Previous Page       Next Page

Accsoft Computer Technology Pty Ltd     ABN: 98 065 617 549
PO Box 892, Epping NSW 1710         Level 1, Epping Office Park, 242 Beecroft Rd, Epping NSW 2121, Australia
Tel: Sydney - (02)98691668     National - 1300-881668         Fax: (02)98691866
© Copyright 2003 Accsoft Computer Technology Pty Ltd