/// <summary> /// Sends data asynchronously to a remote host /// </summary> /// <param name="e">The SecureSocketEventArgs object to use for this asynchronous socket operation</param> /// <returns></returns> public bool SendAsync(SecureSocketEventArgs e) { if (m_Disposed == true) { throw new ObjectDisposedException("m_SecureSocket"); } e.SetSecureSocket(this); List <Record> listOfRecords = m_Bus.HandleDataToBeSent(e.Buffer, e.Offset, e.Count); byte[] data = Records.Merge(listOfRecords); e.SetBufferInternal(data, 0, data.Length); bool result = m_InternalSocket.SendAsync(e.InternalEventArgs); return(result); }
/// <summary> /// Initiates a handshake with a remote host /// </summary> /// <param name="e">The SslSocketArgs object to use for this asynchronous socket operation</param> public bool SecureConnectAsync(SecureSocketEventArgs e) { if (m_Disposed == true) { throw new ObjectDisposedException("m_SecureSocket"); } bool result; m_ConnectType = 2; if (!m_InternalSocket.Connected) { m_IsSecureConnected = false; } if (m_IsSecureConnected) { return(true); } if (m_InternalSocket.Connected) { e.SetSecureSocket(this); m_Bus = new Bus(); List <Record> listOfRecords = m_Bus.StartHandshake(); byte[] data = Records.Merge(listOfRecords); Console.WriteLine("Internal Socket is connected. " + BitConverter.ToString(data)); e.SetBufferInternal(data, 0, data.Length); result = m_InternalSocket.SendAsync(e.InternalEventArgs); } else { e.SetSecureSocket(this); m_Bus = new Bus(); result = m_InternalSocket.ConnectAsync(e.InternalEventArgs); } return(result); }