private void DoConnect(EndPoint address) { ReportConnectFailure(() => { _channel = DatagramChannel.Open(); _channel.ConfigureBlocking(false); var socket = _channel.Socket; _connect.Options.ForEach(x => x.BeforeDatagramBind(socket)); if (_connect.LocalAddress != null) { socket.Bind(_connect.LocalAddress); } _channel.Connect(_connect.RemoteAddress); _channelRegistry.Register(_channel, SocketAsyncOperation.Receive, Self); }); _log.Debug("Successfully connected to [{0}]", _connect.RemoteAddress); }
/// <summary> /// TBD /// </summary> /// <param name="udp">TBD</param> /// <param name="channelRegistry">TBD</param> /// <param name="commander">TBD</param> /// <param name="options">TBD</param> public UdpSender(UdpExt udp, IChannelRegistry channelRegistry, IActorRef commander, IEnumerable <Inet.SocketOption> options) { _udp = udp; _commander = commander; _options = options; _channel = new Func <DatagramChannel>(() => { var datagramChannel = DatagramChannel.Open(); datagramChannel.ConfigureBlocking(false); var socket = datagramChannel.Socket; _options.ForEach(x => x.BeforeDatagramBind(socket)); return(datagramChannel); })(); channelRegistry.Register(_channel, SocketAsyncOperation.None, Self); }
public virtual DatagramChannel Create() { return(DatagramChannel.Open()); }