c# - UDPClient stream is slightly delayed. Can I speed it up? -


so have 2 c# applications running on same machine. communicate via udpclient (one application opens streams , sets this:

udp1server.client.setsocketoption(socketoptionlevel.socket, socketoptionname.reuseaddress, true); 

the other application can connect , communicate messages @ acceptable rate, issue there slight delay of maybe half second before recieved on other app.

seeing these communicating messages on same machine there should no lag right?

the funny messages being send smartphone via bluetooth app 1, via udp app 2. , bluetooth stream faster communication between 2 apps on same machine?!

this application sends data:

static void unitythread()     {         try         {             while (true)             {                 if (bluetoothclients[0].connected)                 {                      byte[] sendbuf = encoding.ascii.getbytes(latestdata[0]);                      udp1server.send(sendbuf, sendbuf.length);                 }                 thread.sleep(1);             }         }          catch (socketexception e) { }     } 

this application receives data:

void consolethread(){     while (!_isquitting)     {         try         {             byte[] receivebytes = udp1server.receive(ref localpt1);             string returndata = encoding.ascii.getstring(receivebytes);              udplastvalue = returndata;         }         catch (exception e)         {             print("errir in udp1 " + e.tostring());         }         thread.sleep(1);     } } 

thanks bunch

fixed removing sleep on reciever.


Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -