Ive been creating a Auto Patch system in C#
Where if people connect to the server they get the latest patches if they dont have it. but ive got a program when auto patching only auto patches latest patch can anyone help me with this problem its meant to get all patches what haven't been downloaded.
Script
using System;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
public class ThreadedTcpSrvr
{
//server post to Liston to.
const int listenPort = 9528;
private TcpListener client;
public ThreadedTcpSrvr()
{
client = new TcpListener(IPAddress.Any, listenPort);
client.Start();
Console.WriteLine("Waiting for clients on port " + listenPort);
while (true)
{
while (!client.Pending())
{
Thread.Sleep(1000);
}
ConnectionThread newconnection = new ConnectionThread();
newconnection.threadListener = this.client;
Thread newthread = new Thread(new
ThreadStart(newconnection.HandleConnection));
newthread.Start();
}
}
public static void Main()
{
ThreadedTcpSrvr server = new ThreadedTcpSrvr();
}
}
class ConnectionThread
{
public TcpListener threadListener;
private static int connections = 0;
public void HandleConnection()
{
int recv;
byte[] data = new byte[1024];
TcpClient client = threadListener.AcceptTcpClient();
NetworkStream ns = client.GetStream();
connections++;
Console.WriteLine("New client accepted: {0} active connections",
connections);
//current latest patch
const string clientVer = "1004";
string msgUpdate = "UPDATE";
string msgReady = "READY";
//ip
string msgIP = "58.54.48.123";
//where to get file
string msgLocation = "/enzf/1004.exe";
while (true)
{
try
{
data = new byte[1024];
recv = ns.Read(data, 0, data.Length);
string message = Encoding.ASCII.GetString(data).Substring(0, clientVer.Length);
switch (message)
{
case clientVer:
data = Encoding.ASCII.GetBytes(msgReady);
ns.Write(data, 0, data.Length);
goto done;
default:
data = Encoding.ASCII.GetBytes(msgUpdate + " " + msgIP + " " + msgLocation);
ns.Write(data, 0, data.Length);
goto done;
}
}
catch
{
break;
}
}
done:
connections--;
Console.WriteLine("Client {0}:{1} disconnected: {2} active connection(s)", IPAddress.Parse(((IPEndPoint)client.Client.RemoteEndPoint).Address.ToString()), ((IPEndPoint)client.Client.RemoteEndPoint).Port.ToString(), connections);
ns.Close();
client.Close();
}
}
//////////
How do i get it to get earler patches.
E.G. im set as patch 1000 and current patch is 1004. how do i get it to download patch 1001,1002,1003 and 1004
Please help me. And sorry if this is in the wrong section.