UdpClient doesn't receive data with ReceiveAsync but does with BeginReceive
Hello all, I'm making a torrent client and I'm facing a problem
4 Replies
I have 2 versions of a
ExecuteUDPRequest
method, 1 using BeginReceive to receive and one using ReceiveAsync, the ReceiveAsync
hangs, it doesn't crash or anything, just hangs.
BeginReceive:
ReceiveAsync:
the weird thing is, ReceiveAsync
does not respect my Cancellation Token, it just hangs forever.
no exceptions thrown either
I find it particularly weird that ReceiveAsync
does not take in an endpoint as a parameter like BeginReceive
does but there is no overload where it takes such a parameter
any knows why this might hang?ps you don't need a timer for the cancellationTokenSource
you can just pass the interval to it in the constructor iirc
also you haven't said if the BeginReceive version calls successfully EndReceive
It does, basically the one with
BeginReceive
& EndReceive
is my current working version
I can't run it multiple times though
I might take a look at the .net library source to see exactly how ReceiveAsync works so I might get a clue or try to use Socket
instead of UdpClient
thats like my other 2 options right now but I can't for the life of me figure out why this hangsi don't think that would help
if you just do a little local test with the udpclient i think you can sort it out faster