Data transmission when using SSL

  1. last week

    Tim S

    Dec 5 Canterbury, UK

    Suppose I open a socket connection to a remote host, using either an SSLSocket (classic) or having set a particular security level on a TCPSocket (new framework). Suppose also the connection attempt succeeds and I now wish to send a short message to the host using socket.write or .writedata.

    It's unclear to me whether each such .write is encrypted and sent ASAP or whether there is an attempt to group them together before sending. All my writes, even those of only a few bytes, seem to go out immediately so I am curious as to how this is organised.

    I'm looking into this because at the moment I'm waiting for data to be transmitted (by polling and checking status) before moving on to a read, and I wonder whether I need to bother (I note that the new framework doesn't have a flush method). One place where it might be important is at the moment the connection is to be terminated. It appears that I must send QUIT to the other end (a mail host), otherwise it doesn't delete mails for which I've requested deletion. As I'm doing all this in a thread, I don't want to send the QUIT and then have the thread exit before the message is actually sent to the remote end.

    Any comments as to how this works would be appreciated.

  2. shao s

    Dec 5 Pre-Release Testers Sudbury, Ontario, Canada

    Mail servers only mark the messages for deletion, and only delete the emails upon the disconnect from the server.. This allows for someone to change their mind about deleting the email or not..

    Xojo.Net.TCPSocket is only available on iOS, so you might be better to move this to the iOS forum..

  3. Tim S

    Dec 5 Canterbury, UK

    @shao s Xojo.Net.TCPSocket is only available on iOS, ...

    OK - I'd overlooked that.

    Basically I want to know whether, with the old framework and an SSLSocket, I need to use flush() to wait for a write to complete (or do a poll() in a loop and wait for completion status) or whether this is unnecessary.

  4. Peter J

    is not verified Dec 5 KwaZulu-Natal, South Africa

    In the days of RealBasic, flush was often lethal, causing all kinds of mayhem. I can't comment on flush in Xojo.

  5. shao s

    Dec 5 Pre-Release Testers Sudbury, Ontario, Canada

    I use it in Xojo.. I have a custom socket, based on the SSLSocket and I use .Flush as some of the commands are too short to trigger the sending.. As the docs note:

    This function can be useful in point-to-point communication over sockets and similar connections: To optimize for transmission performance, some types of output streams try to collect small pieces of written data into one larger piece for sending instead of sending each piece out individually. By calling Flush, the data collection is stopped and the data is sent without further delay, reducing latency.

  6. Tim S

    Dec 5 Canterbury, UK

    I've seen on a post in this forum with what purports to be how flush() is implemented. It claimed that flush() is just a loop in which a poll() is done, and a test for BytesLeftToSend, and returns when this is zero. Nothing about stopping data collection. It didn't even appear to test for isConnected.

    I've used flush() when isConnected happened to be false; this appears to send the app into a tight loop inside flush() which renders the debugger useless. Since then I've used my own version of flush() which behaves rather better. But I still don't know whether I actually need to do this.

  7. shao s

    Dec 5 Pre-Release Testers Sudbury, Ontario, Canada

    I just overloaded the .Write method and call .Flush in there, that way I don't worry about calling it randomly..

or Sign Up to reply!