public static void SendUDPData(IPEndPoint clientEndPoint, Packet p) { try { if (clientEndPoint != null) { udpListener.BeginSend(p.ToArray(), p.Length(), clientEndPoint, null, null); } } catch (Exception ex) { Console.WriteLine($"Error sending data via udp: {ex}"); } }
public static void SendUDPData(IPEndPoint clientEndPoint, Packet packet) { try { if (clientEndPoint != null) { udpListener.BeginSend(packet.ToArray(), packet.Length(), clientEndPoint, null, null); } } catch (Exception e) { Console.WriteLine($"Error on sending data to client end point {clientEndPoint}, {e}"); } }
/// <summary>Sends a packet to the specified endpoint via UDP.</summary> /// <param name="_clientEndPoint">The endpoint to send the packet to.</param> /// <param name="_packet">The packet to send.</param> public static void SendUDPData(IPEndPoint _clientEndPoint, Packet _packed) { try { if (_clientEndPoint != null) { udpListener.BeginSend(_packed.ToArray(), _packed.Length(), _clientEndPoint, null, null); } } catch (Exception ex) { Console.WriteLine($"Error sending data to {_clientEndPoint} via UDP: {ex}"); } }
public static void SendUDPData(IPEndPoint endPoint, Packet packet) { try { if (endPoint != null) { udpListener.BeginSend(packet.ToArray(), packet.Length(), endPoint, null, null); } } catch (Exception ex) { Console.WriteLine($"Error sending data to {endPoint} via UDP: {ex}"); } }
/// <summary>Sends data to the client via UDP.</summary> /// <param name="packet">The packet to send.</param> public void SendData(Packet packet) { try { packet.InsertInt(instance.myId); // Insert the client's ID at the start of the packet if (socket != null) { socket.BeginSend(packet.ToArray(), packet.Length(), null, null); } } catch (Exception ex) { Debug.Log($"Error sending data to server via UDP: {ex}"); } }