Posts

Showing posts with the label udp

UDP maximum packet size through loopback interface

Image
Clash Royale CLAN TAG #URR8PPP UDP maximum packet size through loopback interface I want to use UDP to do Interprocesses communication, I know the maximum size for a UDP datagram is ~64K. but whether is that true for loopback? 1 Answer 1 TL;DR : 64k, if you don't care about IP fragmentation. MTU if you do. Even though UDP max packet size is 64k, the actual transfer size is governed by the interface's MTU. Any packet larger than the MTU (including IP and UDP overhead) will be fragmented to multiple layer-2 packets. So, while you can always send a 64k UDP packet, you may end up with more than one IP packet, which add latency and increase the chance of packet drop (if one fragment is lost - all the datagram is lost). The good news is that you don't have to worry about fragmentation yourself - the kernel will take care of fragmentation and reassembly so your application will see a single dat...

Unity UDP - Can't send and receive at the same time?

Unity UDP - Can't send and receive at the same time? I've been trying to send coordinates of the players vector to the UDP server which is written in NodeJS. However, when I try to send the coordinates and receive them modified afterwards nothing shows. If I modify the server to send me info constantly, it works. Seems as if I can't send and receive at the same time. using System.Collections.Generic; using UnityEngine; using System; using System.Collections; using System.Net; using System.Net.Sockets; using System.Text; using System.Threading; public class PlayerBehavior : MonoBehaviour { private UdpClient udpServer; public GameObject cube; private Vector3 tempPos; private Thread t; public float movementSpeed; private long lastSend; private IPEndPoint remoteEP; void Start() { udpServer = new UdpClient(41234); t = new Thread(() => { while (true) { this.receiveData(); } }); ...