private NorocPacket SendAck(NorocPacket msg, int timeout) { int length = msg.GetFullLength(); byte[] buffer = new byte[NorocPacket.GetMaxSize()]; connection.Send(msg.GetBytes(), msg.GetFullLength()); buffer = Recv(timeout); if (buffer.Length <= 0) return null; return new NorocPacket(buffer); }
private NorocPacket SendResend(NorocPacket msg, UInt16 maxResend, int timeout) { int length = msg.GetFullLength(); byte[] buffer = new byte[NorocPacket.GetMaxSize()]; connection.Send(msg.GetBytes(),msg.GetFullLength()); /* If we have data, or we have no tries left */ for (int i = 0; i < maxResend || buffer.Length > 0; i++) buffer = Recv(timeout); if (buffer.Length <= 0) return null; return new NorocPacket(buffer); }
public NorocPacket SendPacket(NorocPacket msg, int maxResend, int timeout) { if (connection == null || ip == null) return null; switch (msg.Options & 0xC0){ case (UInt16)NorocProtocol.NOROC_PROTOCOL_REQ_ACK: return SendAck(msg, timeout); case (UInt16)NorocProtocol.NOROC_PROTOCOL_REQ_RESEND: return SendResend(msg, (UInt16)maxResend, timeout); case (UInt16)NorocProtocol.NOROC_PROTOCOL_REQ_NOACK: SendNoAck(msg); break; } return null; }
private void SendNoAck(NorocPacket msg) { connection.Send(msg.GetBytes(), msg.GetFullLength()); }