/// <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); }
/// <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> /// Connects asynchronously to a remote host /// </summary> /// <param name="e">The SecureSocketEventArgs object to use for this asynchronous socket operation</param> /// <returns>Type: System.Boolean /// Returns true if the I/O is pending, false if the operation completed synchronously</returns> public bool ConnectAsync(SecureSocketEventArgs e) { if (m_Disposed == true) { throw new ObjectDisposedException("m_SecureSocket"); } if (m_InternalSocket.Connected) { return(true); } m_ConnectType = 1; e.SetSecureSocket(this); bool result = m_InternalSocket.ConnectAsync(e.InternalEventArgs); return(result); }
/// <summary> /// Receive data asynchronously from a remote host /// </summary> /// <param name="e">The SslSocketArgs object to use for this asynchronous socket operation</param> /// <returns>Type: System.Boolean /// Returns true if the I/O is pending, false if the operation completed synchronously</returns> public bool ReceiveAsync(SecureSocketEventArgs e) { if (m_Disposed) { throw new ObjectDisposedException("m_SecureSocket"); } int available = e.CheckQueues(m_Bus); if (available != 0) { e.RaiseCompletedForReceive(available); return(true); } else { e.SetSecureSocket(this); e.SetBufferForReceive(); bool result = m_InternalSocket.ReceiveAsync(e.InternalEventArgs); return(result); } }