Skip to content

Instantly share code, notes, and snippets.

@jakesays-old
Created August 11, 2017 18:18
Show Gist options
  • Save jakesays-old/c0a50c811d252fc8e8ccb00e52114a7c to your computer and use it in GitHub Desktop.
Save jakesays-old/c0a50c811d252fc8e8ccb00e52114a7c to your computer and use it in GitHub Desktop.
Connection abstraction lifted from WCF
using System;
using System.Diagnostics;
using System.Net;
using System.Threading;
using Std.Net.Support;
namespace Std.Net
{
public interface IConnection
{
byte[] AsyncReadBuffer { get; }
int AsyncReadBufferSize { get; }
TraceEventType ExceptionEventType { get; set; }
IPEndPoint RemoteIPEndPoint { get; }
void Abort();
void Close(TimeSpan timeout, bool asyncAndLinger);
void Shutdown(TimeSpan timeout);
AsyncCompletionResult BeginWrite(byte[] buffer,
int offset,
int size,
bool immediate,
TimeSpan timeout,
WaitCallback callback,
object state);
void EndWrite();
void Write(byte[] buffer, int offset, int size, bool immediate, TimeSpan timeout);
void Write(byte[] buffer, int offset, int size, bool immediate, TimeSpan timeout, BufferManager bufferManager);
int Read(byte[] buffer, int offset, int size, TimeSpan timeout);
AsyncCompletionResult BeginRead(int offset, int size, TimeSpan timeout, WaitCallback callback, object state);
int EndRead();
// very ugly listener stuff
object DuplicateAndClose(int targetProcessId);
object GetCoreTransport();
IAsyncResult BeginValidate(Uri uri, AsyncCallback callback, object state);
bool EndValidate(IAsyncResult result);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment