}
}
- /// <summary>
- /// Internal call to start listening once this socket has been constructed and is ready.
- /// </summary>
- internal void StartListening()
- {
- //Start receiving data
- try
- {
- StartWaitingForHeader();
- }
- catch (SocketException e)
- {
- throw new HazelException("A Socket exception occured while initiating a receive operation.", e);
- }
- }
-
/// <inheritdoc />
public override void Connect()
{
}
//Start receiving data
- StartListening();
+ try
+ {
+ StartListening();
+ }
+ catch (SocketException e)
+ {
+ throw new HazelException("A Socket exception occured while initiating the first receive operation.", e);
+ }
- //Set connected
- State = ConnectionState.Connected;
+ //Set connected
+ State = ConnectionState.Connected;
}
}
}
catch (SocketException e)
{
- HandleDisconnect(new HazelException("A Socket exception occured while initiating a receive operation.", e));
+ HandleDisconnect(new HazelException("A Socket exception occured while initiating a body receive operation.", e));
}
}
void BodyReadCallback(byte[] bytes)
{
//Begin receiving from the start
- StartWaitingForHeader();
+ try
+ {
+ StartWaitingForHeader();
+ }
+ catch (SocketException e)
+ {
+ HandleDisconnect(new HazelException("A Socket exception occured while initiating a body receive operation.", e));
+ }
Statistics.LogReceive(bytes.Length, bytes.Length + 4);
/// <summary>
/// Starts this connections waiting for the header.
/// </summary>
- void StartWaitingForHeader()
+ internal void StartWaitingForHeader()
{
StartWaitingForBytes(4, HeaderReadCallback);
}
}
catch (SocketException e)
{
- HandleDisconnect(new HazelException("A Socket exception occured while initiating a receive operation.", e));
+ HandleDisconnect(new HazelException("A Socket exception occured while initiating a chunk receive operation.", e));
return;
}
}