Exemple #1
0
        public static SocketUdpServer Bind(int port, int bufferSize)
        {
            var server = new SocketUdpServer(bufferSize);

            server.socket.Bind(new IPEndPoint(IPAddress.Any, port));
            return(server);
        }
        /// <summary>
        /// create UDP socket and bind for listen.
        /// </summary>
        /// <param name="domainSocketPath">path to socket</param>
        /// <param name="bufferSize">socket buffer size</param>
        /// <exception cref="SocketException">unix domain socket not supported or socket already exists even if it is not bound</exception>
        /// <returns>UDP server with bound socket</returns>
        public static SocketUdpServer BindUds(string domainSocketPath, int bufferSize)
        {
            var server = new SocketUdpServer(bufferSize, AddressFamily.Unix, ProtocolType.IP);

            server.socket.Bind(new UnixDomainSocketEndPoint(domainSocketPath));
            return(server);
        }
Exemple #3
0
        public UdpWorker(MessagePipeInterprocessUdpOptions options, IAsyncPublisher <IInterprocessKey, IInterprocessValue> publisher)
        {
            this.cancellationTokenSource = new CancellationTokenSource();
            this.options   = options;
            this.publisher = publisher;

            this.server = new Lazy <SocketUdpServer>(() =>
            {
                return(SocketUdpServer.Bind(options.Port, 0x10000));
            });

            this.client = new Lazy <SocketUdpClient>(() =>
            {
                return(SocketUdpClient.Connect(options.Host, options.Port, 0x10000));
            });

#if !UNITY_2018_3_OR_NEWER
            this.channel = Channel.CreateUnbounded <byte[]>(new UnboundedChannelOptions()
            {
                SingleReader = true,
                SingleWriter = false,
                AllowSynchronousContinuations = true
            });
#else
            this.channel = Channel.CreateSingleConsumerUnbounded <byte[]>();
#endif
        }
        public static SocketUdpServer Bind(int port, int bufferSize)
        {
            var server = new SocketUdpServer(bufferSize, AddressFamily.InterNetwork, ProtocolType.Udp);

            server.socket.Bind(new IPEndPoint(IPAddress.Any, port));
            return(server);
        }