opened socket in IDE prevents script changes
Alex Tweedly
alex at tweedly.net
Fri Jan 15 12:22:57 EST 2021
On 15/01/2021 14:46, matthias rebbe via use-livecode wrote:
> Alex,
> for a new project which should include socket communication i have to prototype a short "demo" and i was already wondering if i need to have running 2 instances of the LC IDE for development.
>
> But now you wrote that you had one server and even multiple client stacks opened in LC.
> So do i understand it correctly that both, server and client stack, can communicate with each other using sockets in one instance of the LC IDE?
Yes. A couple of cautions ...
- make sure your handlers are carefully named
I had a bad habit of using the same name (_gotpacket) each time I
wrote a socket-handling stack,
so I had 'open socket ... with message "_gotpacket" '
and then I used the same name when I wrote the server !!
- beware "resetall". In the server stack, I do something like
> -- would usually do
> -- resetAll
> -- but this causes problems with testing when you have both a client
> -- and a server within the IDE of Rev
> -- so here we will only reset those opensockets which have no
> 'host' part
> -- intending this to be the ones which we have a current 'accept'
> repeat for each line tSock in the openSockets
> if ":" is not in tSock then close socket tSock
> end repeat
>
and in the client stacks I do the inverse (if ":" is in tSock ...). Note
this is still a problem when you have multiple client stacks in the same
IDE.
Finally,
- when in doubt during testing - first reset the server, then the client.
Good luck,
Alex.
More information about the use-livecode
mailing list