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); }
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 }
/// <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); }
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); }