/// <summary> /// Executes the request on the base handle. /// </summary> public void Connect() { var addr = SockAddr.FromIpEndPoint(this.EndPoint); Libuv.EnsureSuccess(Libuv.uv_tcp_connect(this, this.BaseHandle, ref addr, _UvConnectCallback)); this.EndPoint = null; }
/// <summary> /// Binds the handle to the specified end point. /// </summary> /// <param name="endPoint"></param> public void Bind(IPEndPoint endPoint) { this.EnsureCallingThread(); var addr = SockAddr.FromIpEndPoint(endPoint); Libuv.EnsureSuccess(Libuv.uv_tcp_bind(this, ref addr, 0)); }
public void EndPointConversionTest(string ipString, AddressFamily addressFamily, bool isIPv4MappedToIPv6, string mappedIp) { var ip = IPAddress.Parse(ipString); var randomPort = _Random.Next(0, 65536); var endPoint = new IPEndPoint(ip, randomPort); var resultEndPoint = SockAddr.FromIpEndPoint(endPoint).ToIpEndPoint(); Assert.Equal(endPoint.AddressFamily, resultEndPoint.AddressFamily); Assert.Equal(endPoint.Address.ToString(), resultEndPoint.Address.ToString()); Assert.Equal(randomPort, resultEndPoint.Port); Assert.Equal(ipString, resultEndPoint.Address.ToString()); Assert.Equal(addressFamily, resultEndPoint.AddressFamily); Assert.Equal(isIPv4MappedToIPv6, resultEndPoint.Address.IsIPv4MappedToIPv6); if (mappedIp != null) { Assert.Equal(mappedIp, resultEndPoint.Address.MapToIPv4().ToString()); } }
public void ArgumentNullExceptionTest() { Assert.Throws <ArgumentNullException>(() => SockAddr.FromIpEndPoint(null)); }