Thanks Phil. Yes I learned the hard way with my SQL Agent to base64encode 
anything over sockets. And yes I do append a numtochar(13) coming and going and 
strip it off before decoding and read until numToChar(13). I don't use cr 
because I am uncertain how each OS platform treats it. The Server Agent could 
be running on anything in the future. 

I also instituted a debugging log and determined the File Server Agent is 
getting the payload and sending the result back, but for whatever reason the 
client side is not getting the result. It may be that I have to initiate some 
kind of delay on the server side because the assumption has to be that the 
reply is getting sent before the client starts listening. 

Bob S


> On Apr 4, 2023, at 20:06, Phil Davis via use-livecode 
> <use-livecode@lists.runrev.com> wrote:
> 
> Bob -
> 
> Don't use EOF. It's broken since forever ago.
> 
> I've done both of the following methods with success:
> 
> -- either --
> 
> End your data stream with a CR, and then on the receiving end "read from 
> socket XYZ for 1 line". This assumes that the data stream itself doesn't 
> contain any CRs. I normally base64-encode the data stream, then replace CR 
> with empty in the encoded string. This doesn't interfere with base64Decoding 
> on the receiving end - it'll still work fine.
> 
> -- or --
> 
> Make line 1 of your data stream an integer that is the number of bytes in 
> line 2 of your data stream
> Make line 2 of your data stream the data you want to send
> 
> Then on the receiving end, do a two-step:
> - read from socket XYZ for 1 line
> - put it into tDataLength
> - read from socket XYZ for tDataLength bytes
> 
> 
> That's all I got :-)
> Phil Davis
> 
> 
> 
> On 4/4/23 1:47 PM, Bob Sneidar via use-livecode wrote:
>> I have sockets working in my File Server Agent, but only using non-blocking 
>> calls, that is using "with message". Removing the "with message" bit does 
>> not return any response from the server agent.
>> 
>> For instance I send a payload using
>> write payload to socket tSocket with message "messageReceived"
>> The messageReceived handler gets triggered, and I can then
>> read from socket tSocket until EOF -- or other delimiter
>> it will then contain the response from the File Server Agent.
>> 
>> If however I use
>> write payload to socket tSocket -- blocking
>> read from socket tSocket until EOF -- or some other delimiter doesn't matter
>> 
>> the call times out and nothing ends up in the it or result variables.
>> 
>> I can (and have) made the non-blocking method work, but that means I have to 
>> send all the files I want to transfer all at once, because if I send them 
>> one at a time, I need to know if the last transfer succeeded before 
>> continuing.
>> 
>> Does anyone have an example of a blocking socket server? The example in 
>> Livecode Lessons really only focuses on non-blocking calls.
>> 
>> Bob S
>> 
>> 
>> _______________________________________________
>> use-livecode mailing list
>> use-livecode@lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your subscription 
>> preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>> 
> 
> -- 
> Phil Davis
> (503) 307-4363
> 
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode@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@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to