Socket.Send best practise
<p>I'm attempting to improve some of our networking code, and here I need to use <code>Socket.Send</code>. </p>

<p>However, MSDN states that it's the developers own responsibility to handle retries, and since the Socket.Send method won't necessary send all data in a single request (depends on buffer size), I've decided to go with following loop:</p>

<pre><code>try
{
    int timeout = TimeSpan.FromSeconds(10).Milliseconds;
    int waitTime = TimeSpan.FromMilliseconds(30).Milliseconds;

    Socket socket = tcpClient.Client;
    socket.SendTimeout = timeout ;

    int offset = 0;

    while (offset != data.Length)
    {
        if (socket.Poll(waitTime , SelectMode.SelectWrite))
        {
            offset += socket.Send(data, offset, data.Length - offset, SocketFlags.None);
        }
    }
}
catch (SocketException)
{
    tcpClient.Close();
}
</code></pre>

<p>However, I'm uncertain regarding the offset, as it's zero based, which probably would result in the offset missing a single byte on every loop here, or am I wrong?</p>

<p>Also, are there any other best practises to be concerned about here?</p>
