As
with any networking textbook, we could go top down or bottom up. To give the
journey an overview, we talk about the lowest level (i.e. TCP transport)
abstraction that we use and the highest level abstraction we provide for
caller. Interesting reader will then get a sense what could be in the middle.
The
abstraction we use from TCP transport is the Sockets API, in particular, these
few calls are used.
public IAsyncResult BeginReceive(byte[] buffer, int offset, int size, SocketFlags socketFlags, AsyncCallback callback, object state);
public IAsyncResult BeginSend(IList<ArraySegment<byte>> buffers, SocketFlags socketFlags, AsyncCallback callback, object state);
The
establishment/teardown of the socket (i.e. TCP bind/listen/accept/connect/close)
is outside of the scope of this library, this library simply assumes one.
Note
that we use a complicated variant for the send method. The flexibility of the
sockets API to read from discontinuous regions to send data allows me to avoid
copying data frames comes from various data streams.
The
current version ignored transport errors – a huge mistake – we should improve
it.
No comments :
Post a Comment