/// <summary> /// expect packet from transport.<para/> /// the underlayer transport must be TcpClient, Stream or NetbiosClient. /// </summary> /// <param name="timeout"> /// a TimeSpan object that indicates the timeout to expect event. /// </param> /// <returns> /// a StackPacket object that specifies the received packet. /// </returns> /// <exception cref="ObjectDisposedException"> /// thrown when this object is disposed. /// </exception> /// <exception cref="InvalidOperationException"> /// thrown when stream client is not connected, must invoke Connect() first. /// </exception> public StackPacket ExpectPacket(TimeSpan timeout) { if (disposed) { throw new ObjectDisposedException("StreamTransport"); } if (this.stream == null) { throw new InvalidOperationException( "stream client is not connected, must invoke Connect() first."); } return(ExpectSinglePacketVisitor.Visit( this.buffer, this.decoder, this.localEndPoint, timeout, this.packetCache)); }
/// <summary> /// expect packet from transport.<para/> /// the underlayer transport must be NetbiosTransport, Stream or NetbiosClient. /// </summary> /// <param name="timeout"> /// a TimeSpan object that indicates the timeout to expect event. /// </param> /// <returns> /// a StackPacket object that specifies the received packet. /// </returns> /// <exception cref="InvalidOperationException"> /// thrown when the underlayer transport is not NetbiosTransport, Stream and NetbiosClient. /// </exception> /// <exception cref="ObjectDisposedException"> /// thrown when this object is disposed. /// </exception> /// <exception cref="InvalidOperationException"> /// thrown when netbios client is not connected to server, must invoke Connect() first. /// </exception> public StackPacket ExpectPacket(TimeSpan timeout) { if (disposed) { throw new ObjectDisposedException("NetbiosClientTransport"); } if (this.transport == null) { throw new InvalidOperationException( "netbios client is not connected to server, must invoke Connect() first."); } return(ExpectSinglePacketVisitor.Visit( this.buffer, this.decoder, this.remoteEndPoint, timeout, this.packetCache)); }