/// <summary>
/// Send a message to an unconnected host
/// </summary>
public void SendUnconnectedMessage(NetOutgoingMessage msg, string host, int port)
{
if (msg == null)
{
throw new ArgumentNullException("msg");
}
if (host == null)
{
throw new ArgumentNullException("host");
}
if (msg.m_isSent)
{
throw new NetException("This message has already been sent! Use NetPeer.SendMessage() to send to multiple recipients efficiently");
}
if (msg.LengthBytes > m_configuration.MaximumTransmissionUnit)
{
throw new NetException("Unconnected messages too long! Must be shorter than NetConfiguration.MaximumTransmissionUnit (currently " + m_configuration.MaximumTransmissionUnit + ")");
}
IPAddress adr = NetUtility.Resolve(host);
if (adr == null)
{
throw new NetException("Failed to resolve " + host);
}
msg.m_messageType = NetMessageType.Unconnected;
msg.m_isSent = true;
Interlocked.Increment(ref msg.m_recyclingCount);
m_unsentUnconnectedMessages.Enqueue(new NetTuple <IPEndPoint, NetOutgoingMessage>(new IPEndPoint(adr, port), msg));
}