TcpSocketChannel.DoConnect returning true stops channel active being fired
- Dominant language
- C#
- Stars
- 4.3k
- Forks
- 1k
- PR merge metrics
- No merged PRs in 30d
Description
When using UnixEndPoint under Mono on Linux, TcpSocketChannel never becomes active after a call to connect. The reason appears to be that the connection succeeds immediately, on DoConnect returns false.
When creating a subclass (see attached code) which always returns false, then all is well. Also, when TcpSocketChannel tries to create a Socket, it always provides ProtocolType.IPv6. For unix domain sockets that needs to be ProtocolType.Unspecified otherwise an exception is thrown.
```csharp
using System.Net;
using System.Net.Sockets;
using DotNetty.Transport.Channels.Sockets;
namespace agentx
{
internal class UnixSocketChannel : TcpSocketChannel
{
public UnixSocketChannel()
: base(new Socket(AddressFamily.Unix, SocketType.Stream, ProtocolType.Unspecified))
{
}
protected override bool DoConnect(EndPoint remoteAddress, EndPoint localAddress)
{
base.DoConnect(remoteAddress, localAddress);
// channel never fires active event if indicates that connected already
return false;
}
}
}
```
Contributor guide
Assessment
This issue has not been assessed yet.