protected override IAsyncResult BeginSendAndReceive(MemoryStream data, AsyncCallback callback) { TcpConnEntry entry = pool.Get(uri); try { if (entry.conn.client == null) { entry.Set(CreateClient(uri)); } return(AsyncSend(entry, data, callback)); } catch { entry.Close(); pool.Free(entry); throw; } }
protected override MemoryStream SendAndReceive(MemoryStream data) { TcpConnEntry entry = pool.Get(uri); try { if (entry.conn.client == null) { entry.Set(CreateClient(uri)); } Stream stream = entry.conn.stream; Send(stream, data); data = Receive(stream); } catch { entry.Close(); throw; } finally { pool.Free(entry); } return(data); }