Good evening,
I read this very interesting explanation about UDP-server, UDP-client by
Lukas Gebauer (see below).
My additional question is : does Synapse do UDP checksum verification? I
read somewhere that this is optional for UDP.
In other words, when I send data (10 bytes only) in a UDP datagram, shall I
provide my own checksum (in the data block itself) or can I rely on UDP
checksum mechanism of Synapse?
Thank you
Chris
----------------------------------------------------------------------------
------------------------
RecvPacket allways return full UDP message. :-) If UDP message is bigger
then prepared buffer, then it return WSAEMSGSIZE error... however I read
message size first and I prepare buffer with needed space! You never can
see this error when you using RecvPacket method. ;-)
> What if 2 clients are sending data at the same time and we have
> received a partial message from client A when data from client B is in the
> stream? Will the method return at the end of the A data and the next call
> get B data with the proper sin's set?
UDP is not stream based! It is datagram based. Each datagram have limited
maximum size, and received datagrams are stored in queue. It is not
stream, each datagram is isolated! And each datagram knows from what
source they has been sent.
When you need to read data from UDP socket, then system get first UDP
datagram from queue and return it to application. When you have not space
for datagram in your buffers, then you got error and rest of datagram is
lost! When you try to read datagram again, then you got next datagram.
But as i read before, when you are using recvpacket method, then you
allways read full UDP message.. you not lost anythink.
So, when you read datagram, then it set remote socket information. Next
send operation send datagram back to originator... it send UDP reply
packet. Now you can read next UDP datagram and it set remoteSin by new
value by real sender of readed UDP message. Next send operation is
correct UDP reply too. ;-) UDP packets from various sources are not
mixed, you send your UDP reply to correct addresses.
By this is very easy to write UDP server... just read UDP message by
recvpacket, process it, and then send reply. This you can call in very
simply loop for processing all incomming UDP packets from various
sources.
--
Lukas Gebauer.
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
_______________________________________________
synalist-public mailing list
synalist-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/synalist-public