----- Original Message -----
From: "Rodney Tamblyn" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, August 26, 2001 10:08 PM
Subject: sockets


> I have been having fun working with sockets in Metacard, and in
general everything seems to work fine.
>
> Some socket questions:
>
> When using sockets to read and write I have been using the following
approach: write the length of the packet on a line followed by the
data, at receiving end read for one line, then read for the supplied
number of characters.  What approaches do others use?  You can also
read without specifying a "for" condition, a specified handler will be
called when data arrives.  Are there any advantages/disadvantages of
one approach over the other?
>
> In general, if you have two stacks that are going to have an ongoing
series of communications going backwards and forwards, is it better to
leave the socket open, or always close the socket after each
communication.  I've assumed the latter.


Have you tried using datagram (UDP or connectionless) sockets? This
causes the sent data to arrive as a parameter variable of the arrival
message rather than as a data stream to be read. For example (in event
sequence order):

-- in the receiving stack (at IP address 11.33.55.77) --
  accept datagram connections on port 55555 \
      with message "newConnection"

-- in the sending stack (at IP address 22.44.66.88) --
  put "11.33.55.77:55555" into tDestination
  open datagram socket to tDestination
  write ("data data data data") to tDestination
  close socket tDestination

-- back in the receiving stack --
on newConnection pSenderAddress, pSentData
  answer hostNameToAddress(hostName()) && "says:" & cr \
      & pSenderAddress && "sent the following:" & cr \
      & pSentData
end newConnection


If I got it right, the above code would display this message:
    11.33.55.77 says:
    22.44.66.88 sent the following:
    data data data data


Food for thought.

(I'm not sure if the "newConnection" UDP socket closes automatically
or if it has to be closed with a "close" command.)

Phil

>
> Presumably there is a limit on the number of sockets MC can have
open?
>
> When MC has an open socket, does it periodically attempt to verify
whether the remote party is still present?
>
> Any other comments or tips from people who are experienced using
sockets in Metacard would be appreciated.
>
> Rodney
> --
> --
> Rodney Tamblyn
> Educational Media group
> Higher Education Development Centre, 75 Union Place
> University of Otago, PO Box 56, Dunedin, New Zealand
> ph +64 3 479 7580 Fax +64 3 479 8362
> http://hedc.otago.ac.nz ~ http://rodney.weblogs.com
>
>
> Archives: http://www.mail-archive.com/metacard@lists.runrev.com/
> Info: http://www.xworlds.com/metacard/mailinglist.htm
> Please send bug reports to <[EMAIL PROTECTED]>, not this list.
>
>



Archives: http://www.mail-archive.com/metacard@lists.runrev.com/
Info: http://www.xworlds.com/metacard/mailinglist.htm
Please send bug reports to <[EMAIL PROTECTED]>, not this list.

Reply via email to