[TestMethod]
public void UdpFieldTest()
{
- NetworkEndPoint ep = new NetworkEndPoint(IPAddress.Loopback, 4296);
+ IPEndPoint ep = new IPEndPoint(IPAddress.Loopback, 4296);
- using (UdpConnectionListener listener = new UdpConnectionListener(new NetworkEndPoint(IPAddress.Any, 4296)))
+ using (UdpConnectionListener listener = new UdpConnectionListener(new IPEndPoint(IPAddress.Any, 4296)))
using (UdpConnection connection = new UdpClientConnection(ep))
{
listener.Start();
public void UdpHandshakeTest()
{
byte[] TestData = new byte[] { 1, 2, 3, 4, 5, 6 };
- using (UdpConnectionListener listener = new UdpConnectionListener(new NetworkEndPoint(IPAddress.Any, 4296, IPMode.IPv4)))
- using (UdpConnection connection = new UdpClientConnection(new NetworkEndPoint(IPAddress.Loopback, 4296, IPMode.IPv4)))
+ using (UdpConnectionListener listener = new UdpConnectionListener(new IPEndPoint(IPAddress.Any, 4296)))
+ using (UdpConnection connection = new UdpClientConnection(new IPEndPoint(IPAddress.Loopback, 4296)))
{
listener.Start();
public void UdpUnreliableMessageSendTest()
{
byte[] TestData = new byte[] { 1, 2, 3, 4, 5, 6 };
- using (UdpConnectionListener listener = new UdpConnectionListener(new NetworkEndPoint(IPAddress.Any, 4296, IPMode.IPv4)))
- using (UdpConnection connection = new UdpClientConnection(new NetworkEndPoint(IPAddress.Loopback, 4296, IPMode.IPv4)))
+ using (UdpConnectionListener listener = new UdpConnectionListener(new IPEndPoint(IPAddress.Any, 4296)))
+ using (UdpConnection connection = new UdpClientConnection(new IPEndPoint(IPAddress.Loopback, 4296)))
{
MessageReader output = null;
listener.NewConnection += delegate (NewConnectionEventArgs e)
[TestMethod]
public void UdpUnreliableDataSubsetSendTest()
{
- using (UdpConnectionListener listener = new UdpConnectionListener(new NetworkEndPoint(IPAddress.Any, 4296, IPMode.IPv4)))
- using (UdpConnection connection = new UdpClientConnection(new NetworkEndPoint(IPAddress.Loopback, 4296, IPMode.IPv4)))
+ using (UdpConnectionListener listener = new UdpConnectionListener(new IPEndPoint(IPAddress.Any, 4296)))
+ using (UdpConnection connection = new UdpClientConnection(new IPEndPoint(IPAddress.Loopback, 4296)))
{
listener.Start();
listener.NewConnection += delegate (NewConnectionEventArgs e)
[TestMethod]
public void UdpIPv4ConnectionTest()
{
- using (UdpConnectionListener listener = new UdpConnectionListener(new NetworkEndPoint(IPAddress.Any, 4296, IPMode.IPv4)))
- using (UdpConnection connection = new UdpClientConnection(new NetworkEndPoint(IPAddress.Loopback, 4296, IPMode.IPv4)))
+ using (UdpConnectionListener listener = new UdpConnectionListener(new IPEndPoint(IPAddress.Any, 4296)))
+ using (UdpConnection connection = new UdpClientConnection(new IPEndPoint(IPAddress.Loopback, 4296)))
{
listener.Start();
[TestMethod]
public void MixedConnectionTest()
{
- using (UdpConnectionListener listener2 = new UdpConnectionListener(new NetworkEndPoint(IPAddress.IPv6Any, 4296, IPMode.IPv6)))
+ using (UdpConnectionListener listener2 = new UdpConnectionListener(new IPEndPoint(IPAddress.IPv6Any, 4296), IPMode.IPv6))
{
listener2.Start();
Console.WriteLine("v6 connection: " + ((NetworkConnection)evt.Connection).GetIP4Address());
};
- using (UdpConnection connection = new UdpClientConnection(new NetworkEndPoint("127.0.0.1", 4296, IPMode.IPv4)))
+ using (UdpConnection connection = new UdpClientConnection(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 4296)))
{
connection.Connect();
Assert.AreEqual(ConnectionState.Connected, connection.State);
}
- using (UdpConnection connection = new UdpClientConnection(new NetworkEndPoint(IPAddress.IPv6Loopback, 4296, IPMode.IPv6)))
+ using (UdpConnection connection = new UdpClientConnection(new IPEndPoint(IPAddress.IPv6Loopback, 4296), IPMode.IPv6))
{
connection.Connect();
Assert.AreEqual(ConnectionState.Connected, connection.State);
[TestMethod]
public void UdpIPv6ConnectionTest()
{
- using (UdpConnectionListener listener = new UdpConnectionListener(new NetworkEndPoint(IPAddress.IPv6Any, 4296, IPMode.IPv6)))
+ using (UdpConnectionListener listener = new UdpConnectionListener(new IPEndPoint(IPAddress.IPv6Any, 4296), IPMode.IPv6))
{
listener.Start();
- using (UdpConnection connection = new UdpClientConnection(new NetworkEndPoint("127.0.0.1", 4296, IPMode.IPv6)))
+ using (UdpConnection connection = new UdpClientConnection(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 4296), IPMode.IPv6))
{
connection.Connect();
}
[TestMethod]
public void UdpUnreliableServerToClientTest()
{
- using (UdpConnectionListener listener = new UdpConnectionListener(new NetworkEndPoint(IPAddress.Any, 4296)))
- using (UdpConnection connection = new UdpClientConnection(new NetworkEndPoint(IPAddress.Loopback, 4296)))
+ using (UdpConnectionListener listener = new UdpConnectionListener(new IPEndPoint(IPAddress.Any, 4296)))
+ using (UdpConnection connection = new UdpClientConnection(new IPEndPoint(IPAddress.Loopback, 4296)))
{
TestHelper.RunServerToClientTest(listener, connection, 10, SendOption.None);
}
[TestMethod]
public void UdpReliableServerToClientTest()
{
- using (UdpConnectionListener listener = new UdpConnectionListener(new NetworkEndPoint(IPAddress.Any, 4296)))
- using (UdpConnection connection = new UdpClientConnection(new NetworkEndPoint(IPAddress.Loopback, 4296)))
+ using (UdpConnectionListener listener = new UdpConnectionListener(new IPEndPoint(IPAddress.Any, 4296)))
+ using (UdpConnection connection = new UdpClientConnection(new IPEndPoint(IPAddress.Loopback, 4296)))
{
TestHelper.RunServerToClientTest(listener, connection, 10, SendOption.Reliable);
}
[TestMethod]
public void UdpUnreliableClientToServerTest()
{
- using (UdpConnectionListener listener = new UdpConnectionListener(new NetworkEndPoint(IPAddress.Any, 4296)))
- using (UdpConnection connection = new UdpClientConnection(new NetworkEndPoint(IPAddress.Loopback, 4296)))
+ using (UdpConnectionListener listener = new UdpConnectionListener(new IPEndPoint(IPAddress.Any, 4296)))
+ using (UdpConnection connection = new UdpClientConnection(new IPEndPoint(IPAddress.Loopback, 4296)))
{
TestHelper.RunClientToServerTest(listener, connection, 10, SendOption.None);
}
[TestMethod]
public void UdpReliableClientToServerTest()
{
- using (UdpConnectionListener listener = new UdpConnectionListener(new NetworkEndPoint(IPAddress.Any, 4296)))
- using (UdpConnection connection = new UdpClientConnection(new NetworkEndPoint(IPAddress.Loopback, 4296)))
+ using (UdpConnectionListener listener = new UdpConnectionListener(new IPEndPoint(IPAddress.Any, 4296)))
+ using (UdpConnection connection = new UdpClientConnection(new IPEndPoint(IPAddress.Loopback, 4296)))
{
TestHelper.RunClientToServerTest(listener, connection, 10, SendOption.Reliable);
}
[TestMethod]
public void KeepAliveClientTest()
{
- using (UdpConnectionListener listener = new UdpConnectionListener(new NetworkEndPoint(IPAddress.Any, 4296)))
- using (UdpConnection connection = new UdpClientConnection(new NetworkEndPoint(IPAddress.Loopback, 4296)))
+ using (UdpConnectionListener listener = new UdpConnectionListener(new IPEndPoint(IPAddress.Any, 4296)))
+ using (UdpConnection connection = new UdpClientConnection(new IPEndPoint(IPAddress.Loopback, 4296)))
{
listener.Start();
{
ManualResetEvent mutex = new ManualResetEvent(false);
- using (UdpConnectionListener listener = new UdpConnectionListener(new NetworkEndPoint(IPAddress.Any, 4296)))
- using (UdpConnection connection = new UdpClientConnection(new NetworkEndPoint(IPAddress.Loopback, 4296)))
+ using (UdpConnectionListener listener = new UdpConnectionListener(new IPEndPoint(IPAddress.Any, 4296)))
+ using (UdpConnection connection = new UdpClientConnection(new IPEndPoint(IPAddress.Loopback, 4296)))
{
listener.NewConnection += delegate(NewConnectionEventArgs args)
{
[TestMethod]
public void ClientDisconnectTest()
{
- using (UdpConnectionListener listener = new UdpConnectionListener(new NetworkEndPoint(IPAddress.Any, 4296)))
- using (UdpConnection connection = new UdpClientConnection(new NetworkEndPoint(IPAddress.Loopback, 4296)))
+ using (UdpConnectionListener listener = new UdpConnectionListener(new IPEndPoint(IPAddress.Any, 4296)))
+ using (UdpConnection connection = new UdpClientConnection(new IPEndPoint(IPAddress.Loopback, 4296)))
{
TestHelper.RunClientDisconnectTest(listener, connection);
}
[TestMethod]
public void ServerDisconnectTest()
{
- using (UdpConnectionListener listener = new UdpConnectionListener(new NetworkEndPoint(IPAddress.Any, 4296)))
- using (UdpConnection connection = new UdpClientConnection(new NetworkEndPoint(IPAddress.Loopback, 4296)))
+ using (UdpConnectionListener listener = new UdpConnectionListener(new IPEndPoint(IPAddress.Any, 4296)))
+ using (UdpConnection connection = new UdpClientConnection(new IPEndPoint(IPAddress.Loopback, 4296)))
{
TestHelper.RunServerDisconnectTest(listener, connection);
}
+++ /dev/null
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-
-using System.Net;
-
-namespace Hazel
-{
- /// <summary>
- /// Represents an endpoint to a remote resource on a network.
- /// </summary>
- /// <remarks>
- /// This wraps a <see cref="System.Net.EndPoint"/> for connecting across a network using protocols like TCP or UDP.
- /// </remarks>
- /// <threadsafety static="true" instance="true"/>
- public sealed class NetworkEndPoint : ConnectionEndPoint
- {
- /// <summary>
- /// The <see cref="System.Net.EndPoint">EndPoint</see> this points to.
- /// </summary>
- public EndPoint EndPoint { get; set; }
-
- /// <summary>
- /// The <see cref="IPMode"/> this will instruct connections to use.
- /// </summary>
- public IPMode IPMode { get; set; }
-
- /// <summary>
- /// Creates a NetworkEndPoint from a given <see cref="System.Net.EndPoint">EndPoint</see>.
- /// </summary>
- /// <param name="endPoint">The end point to wrap.</param>
- /// <param name="mode">The IP mode to use.</param>
- public NetworkEndPoint(EndPoint endPoint, IPMode mode = IPMode.IPv4)
- {
- this.EndPoint = endPoint;
- this.IPMode = mode;
- }
-
- /// <summary>
- /// Create a NetworkEndPoint to the specified <see cref="System.Net.IPAddress">IPAddress</see> and port.
- /// </summary>
- /// <param name="address">The IP address of the server.</param>
- /// <param name="port">The port the server is listening on.</param>
- /// <param name="mode">The IP mode to use.</param>
- /// <remarks>
- /// When using this constructor <see cref="EndPoint"/> will contain an <see cref="IPEndPoint"/>.
- /// </remarks>
- public NetworkEndPoint(IPAddress address, int port, IPMode mode = IPMode.IPv4)
- : this(new IPEndPoint(address, port), mode)
- {
-
- }
-
- /// <summary>
- /// Creates a NetworkEndPoint to the specified IP address and port.
- /// </summary>
- /// <param name="IP">A valid IP address of the server.</param>
- /// <param name="port">The port the server is listening on.</param>
- /// <param name="mode">The IP mode to use.</param>
- /// <remarks>
- /// When using this constructor <see cref="EndPoint"/> will contain an <see cref="IPEndPoint"/>.
- /// </remarks>
- public NetworkEndPoint(string IP, int port, IPMode mode = IPMode.IPv4)
- : this(IPAddress.Parse(IP), port, mode)
- {
-
- }
-
- /// <inheritdoc />
- public override string ToString()
- {
- return EndPoint.ToString();
- }
- }
-}