/// <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; Interlocked.Increment(ref msg.m_recyclingCount); m_unsentUnconnectedMessages.Enqueue(new NetTuple <IPEndPoint, NetOutgoingMessage>(new IPEndPoint(adr, port), msg)); }
/// <summary> /// Emit a discovery signal to a single known host /// </summary> public bool DiscoverKnownPeer(string host, int serverPort) { IPAddress address = NetUtility.Resolve(host); if (address == null) { return(false); } DiscoverKnownPeer(new IPEndPoint(address, serverPort)); return(true); }
/// <summary> /// Create a connection to a remote endpoint /// </summary> public NetConnection Connect(string host, int port, NetOutgoingMessage hailMessage) { return(Connect(new IPEndPoint(NetUtility.Resolve(host), port), hailMessage)); }
/// <summary> /// Create a connection to a remote endpoint /// </summary> public NetConnection Connect(string host, int port) { return(Connect(new IPEndPoint(NetUtility.Resolve(host), port), null)); }