diff --git a/MTSC/MTSC.csproj b/MTSC/MTSC.csproj
index 888875c..007acec 100644
--- a/MTSC/MTSC.csproj
+++ b/MTSC/MTSC.csproj
@@ -5,13 +5,13 @@
netcoreapp2.1;net48;netstandard2.0;netcoreapp3.1;net5.0
- 3.2.1
+ 3.2.2
latest
Alexandru-Victor Macocian
MTSC
Modular TCP Server and Client
- 0.3.2.1
- 0.3.2.1
+ 0.3.2.2
+ 0.3.2.2
true
AnyCPU;x64
https://github.com/AlexMacocian/MTSC
diff --git a/MTSC/ServerSide/Server.cs b/MTSC/ServerSide/Server.cs
index 71ca24b..c2ec50c 100644
--- a/MTSC/ServerSide/Server.cs
+++ b/MTSC/ServerSide/Server.cs
@@ -81,6 +81,10 @@ namespace MTSC.ServerSide
///
public int Port { get; set; } = 80;
///
+ /// IPAddress used by the server.
+ ///
+ public IPAddress IPAddress { get; set; } = IPAddress.Any;
+ ///
/// Returns the state of the server.
///
public bool Running { get => listener != null; }
@@ -126,6 +130,28 @@ namespace MTSC.ServerSide
this.certificate = certificate;
this.Port = port;
}
+ ///
+ /// Creates an instance of server.
+ ///
+ /// IPAddress to be used by the server.
+ /// Port to be used by the server.
+ public Server(IPAddress ipAddress, int port)
+ {
+ this.IPAddress = ipAddress;
+ this.Port = port;
+ }
+ ///
+ /// Creates an instance of server.
+ ///
+ /// IPAddress to be used by the server.
+ /// Certificate for SSL.
+ /// Port to be used by the server.
+ public Server(X509Certificate2 certificate, IPAddress ipAddress, int port)
+ {
+ this.certificate = certificate;
+ this.Port = port;
+ this.IPAddress = ipAddress;
+ }
#endregion
#region Public Methods
///
@@ -323,6 +349,16 @@ namespace MTSC.ServerSide
return this;
}
///
+ /// Sets the of the server.
+ ///
+ /// Address used by the server.
+ /// This server object.
+ public Server SetIPAddress(IPAddress iPAddress)
+ {
+ this.IPAddress = iPAddress;
+ return this;
+ }
+ ///
/// Adds a to the server.
///
/// Handler to be added.
@@ -479,7 +515,7 @@ namespace MTSC.ServerSide
public void Run()
{
this.listener?.Stop();
- this.listener = new TcpListener(IPAddress.Any, Port);
+ this.listener = new TcpListener(this.IPAddress, this.Port);
this.listener.Start();
this.running = true;
this.Log("Server started on: " + this.listener.LocalEndpoint.ToString());