/// <summary> /// Sends a message as part of the conversation. /// </summary> /// /// <param name="message"> /// A typed buffer containing the message to send; may be null. /// </param> /// /// <param name="len"> /// The length of the data in <paramref name="message"/>. /// </param> /// /// <param name="flags"> /// Set TPRECVONLY to give up control of the conversation. /// See the Tuxedo tpsend(3c) manual page. /// </param> /// /// <exception cref="TPException"> /// See the Tuxedo tpsend(3c) manual page. /// </exception> /// /// <seealso cref="ATMI.tpsend"/>. public void Send(ByteBuffer message, int len, int flags) { try { ATMI.tpsend(cd, message, len, flags); } catch (TPEEVENT eEvent) { cd = -1; throw eEvent; } }
// Reads data from a FileStream and sends it across a conversational connection. private static void Send(FileStream fs, int cd) { byte[] bytes = new byte[4096]; ByteBuffer buffer = ATMI.tpalloc("CARRAY", null, 4096); try { while (true) { int len = fs.Read(bytes, 0, 4096); if (len == 0) { // End of file return; } buffer.PutBytes(bytes, 0, len); ATMI.tpsend(cd, buffer, len, 0); } } finally { ATMI.tpfree(buffer); } }