Dotnetty's SocketDatagramChannel no have Socket.ReceiveFrom() in DoReadMessages()
- Dominant language
- C#
- Stars
- 4.3k
- Forks
- 1k
- PR merge metrics
- No merged PRs in 30d
Description
dotnetty use for unity 2019.2f in mobile,
udp packet sending is work, but receieving is not work in my case...
and i try see it SocketDatagramChannel.cs ,
and i found SocketDatagramChannel no have Socket.ReceiveFrom() funtions...
maybe right this? please check this code and dotnetty's SocketDatagramChannel.cs
my english not good sorry.
SocketDatagramChannel.cs line 139
https://github.com/Azure/DotNetty/blob/dev/src/DotNetty.Transport/Channels/Sockets/SocketDatagramChannel.cs#L139
----------------------------------------------------------------------------------
protected override int DoReadMessages(List buf)
{
Contract.Requires(buf != null);
SocketChannelAsyncOperation operation = this.ReadOperation;
IByteBuffer data = (IByteBuffer)operation.UserToken;
bool free = true;
try
{
IRecvByteBufAllocatorHandle handle = this.Unsafe.RecvBufAllocHandle;
↓ changed
===============================================================
EndPoint remoteEndPoint = null;
if (this.Socket.Connected)
{
remoteEndPoint = this.Socket.RemoteEndPoint;
}
else
{
remoteEndPoint = operation.RemoteEndPoint;
}
int received = this.Socket.ReceiveFrom(data.Array, data.ArrayOffset + data.WriterIndex, data.WritableBytes, SocketFlags.None, ref remoteEndPoint);
============================================================
//int received = operation.BytesTransferred; <-- source
if (received <= 0)
{
return 0;
}
handle.LastBytesRead = received;
data.SetWriterIndex(data.WriterIndex + received);
EndPoint remoteAddress = operation.RemoteEndPoint;
buf.Add(new DatagramPacket(data, remoteAddress, this.LocalAddress));
free = false;
return 1;
}
finally
{
if (free)
{
data.Release();
}
operation.UserToken = null;
}
}
-------------------------------------------------------------------------------------
Contributor guide
Assessment
This issue has not been assessed yet.