Esempio n. 1
0
        public static SocketUdpClient Connect(string host, int port, int bufferSize)
        {
            var client = new SocketUdpClient(bufferSize);

            client.socket.Connect(new IPEndPoint(IPAddress.Parse(host), port));
            return(client);
        }
Esempio n. 2
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
        }
Esempio n. 3
0
        /// <summary>
        /// create UDP unix domain socket client and connect to server
        /// </summary>
        /// <param name="domainSocketPath">path to unix domain socket</param>
        /// <param name="bufferSize"></param>
        /// <exception cref="SocketException">unix domain socket not supported or server does not exist</exception>
        /// <returns>UDP unix domain socket client</returns>
        public static SocketUdpClient ConnectUds(string domainSocketPath, int bufferSize)
        {
            var client = new SocketUdpClient(bufferSize, AddressFamily.Unix, ProtocolType.IP);

            client.socket.Connect(new UnixDomainSocketEndPoint(domainSocketPath));
            return(client);
        }
Esempio n. 4
0
        public static SocketUdpClient Connect(string host, int port, int bufferSize)
        {
            var ipaddr = IPAddress.Parse(host);
            var client = new SocketUdpClient(bufferSize, ipaddr.AddressFamily, ProtocolType.Udp);

            client.socket.Connect(new IPEndPoint(ipaddr, port));
            return(client);
        }