Socket Comm Sequence Issue

Ken Ray kray at sonsothunder.com
Fri Apr 15 08:59:16 EDT 2005


> 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




More information about the use-livecode mailing list