Socket Comm Sequence Issue

Frank D. Engel, Jr. fde101 at fjrhome.net
Fri Apr 15 09:29:06 EDT 2005


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Sockets are already bidirectional, the trick is to know when which 
program should read data.  Set up one to listen then connect from the 
other.

It turns out that 'read from socket' can be used asynchronously.  You 
can have the handler which executes as a callback trigger another read 
each time in order to set up pseudo-threading of a sort, allowing your 
program to offer bidirectional communication over a single socket.  
That should solve your problem.


On Apr 15, 2005, at 8:59 AM, Ken Ray wrote:

>> i.e. when the accept is triggered, it supplies you with a new socket,
>> and it's usual to use that new  socket to reply to the other host.
>>
>> In each app, have an accept connection - if that happens, then you
>> receive on that socket, and send on the socket supplied by the system
>> when the connection is accepted. (i.e. this app is acting like a
>> "server" for the purpose of the comms).
>>
>> In the app which does the first "send", you send to the other app's
>> known socket, and receive from it. (i.e. act like a client)
>
> OK, I understand that, and am even able to get the new socket, but how 
> does
> the app that is accepting communicate just what the new socket *is* to 
> the
> app that does the first send?
>
> That is, if App 1 is listening (accept), and App 2 opens a socket to 
> App 1,
> App 1's accept message will trigger and I can retrieve the new socket 
> info
> in App 1. But how does that new socket get conveyed to App 2? At 
> first, I
> would have thought that it would be carried on the first parameter of 
> the
> <message> in "open socket with <message>", but when I check that port, 
> it's
> *not* the new one created by App 1; it's the original port used in the 
> "open
> socket" command.
>
> Example:
>
> App 1:
>     accept connections on port 59999 with message AcceptConnected
> App 2:
>     open socket "127.0.0.1:59999" with message OpenConnected
> App 1:
>     --> AcceptConnected triggered
>     on AcceptConnected pSocket
>       put pSocket  --> puts the new socket, like "127.0.0.1:50013"
>     end AcceptConnected
> App 2:
>     --> OpenConnected triggered
>     on OpenConnected pSocket
>       put pSocket  --> puts the old socket: "127.0.0.1:59999"
>     end OpenConnected
>
> We're getting closer...
>
> :-)
>
> Ken Ray
> Sons of Thunder Software
> Web site: http://www.sonsothunder.com/
> Email: kray at sonsothunder.com
>
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
>
>
- -----------------------------------------------------------
Frank D. Engel, Jr.  <fde101 at fjrhome.net>

$ ln -s /usr/share/kjvbible /usr/manual
$ true | cat /usr/manual | grep "John 3:16"
John 3:16 For God so loved the world, that he gave his only begotten 
Son, that whosoever believeth in him should not perish, but have 
everlasting life.
$
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (Darwin)

iD8DBQFCX8Gi7aqtWrR9cZoRAl3lAJ4gr9lYbMYdjmvW3sfbpnS4YaWnMQCfa5zy
OpxOoxns+dtih2zIjsCo+Bs=
=DIbb
-----END PGP SIGNATURE-----



___________________________________________________________
$0 Web Hosting with up to 200MB web space, 1000 MB Transfer
10 Personalized POP and Web E-mail Accounts, and much more.
Signup at www.doteasy.com



More information about the use-livecode mailing list