Using sockets

Peter Haworth pete at lcsql.com
Tue Jan 14 19:14:16 EST 2014


Thanks John.  I think I'm getting a handle on this now.  A client connects
to a port and a socket number identifies that client on the port.  A server
accepts connections on a specific port but then talks to each client that
connects to it via the socket assigned to the client.

I think the confusion in my mind was caused by the way LC identifies the
port/socket..  In both cases showing what is described as a socket consists
of the ip address followed by a colon followed by either a socket number or
a port number.

The dictionary adds to the confusion when, in the write to socket entry, it
says the socket id is an ip address followed by a port when it's actually
followed by a socket.

Also got confused on the read from with/without a message callback.  It's
the form without the message callback that pauses until the read finishes.

The dictionary is confusing on this issue too.  It says if you specify a
callback message, the message is sent "as soon as the read is finished".  I
took that to mean the read command didn;t terminate until its end condition
was met.

However it only mentions the socketTimeoutInterval.in the context of reads
without a callback which is why I was surprised to get the socketTimout
message as a result of read with a callback.  Now I'm wondering if I have
to issue another read from within the socketTimeout handler.  Plus, is the
socketTimeout message sent if the interval expires after a read has started
but before it ends?


Pete
lcSQL Software <http://www.lcsql.com>
Home of lcStackBrowser <http://www.lcsql.com/lcstackbrowser.html> and
SQLiteAdmin <http://www.lcsql.com/sqliteadmin.html>


On Tue, Jan 14, 2014 at 12:13 PM, John Craig <john at splash21.com> wrote:

> Hi, Pete.  If client A connects to server:10100 from 192.168.0.10:12345,
> then the server can send a response back to client A through
> 192.168.0.10:12345.  Each client that connects to the server can be
> identified and communicated with in the same way : via the ip:port that
> they used to send the data.
>
> read from socket with messages doesn't block
>
>
> John.
>
>
>
>
> On 14/01/2014 17:22, Peter Haworth wrote:
>
>> Diving into yet another new are of Livecode for me - sockets.
>>
>> My server issues an accept statement for port 10100.  My client opens
>> socket 10100.  WHen the client connects to the server, the port number I
>> get is not 10100, but some other number which changes on each connection.
>>   When sending messages between the client and server, which of these
>> numbers should I use?
>>
>> My server uses read from socket with a callback message specified.  I have
>> a socketTimeout message handler which fires every time the
>> socketTimeoutInterval expires.  I thought the "read from socket with
>> message" command was blocking and everything would stop until a message is
>> received.  If that's the case, it seems odd that these timeouts should
>> occur?
>>
>> Pete
>> lcSQL Software <http://www.lcsql.com>
>> _______________________________________________
>> use-livecode mailing list
>> use-livecode at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
>>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



More information about the use-livecode mailing list