using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using NLog;

namespace DataClient
{
	public class NETClient
	{
		private Logger log = LogManager.GetCurrentClassLogger();
		private Encoding enc;
		private string ip = "127.0.0.1";
		public string Ip
		{
			get { return ip; }
			set
			{
				if (!IPAddress.TryParse(value, out _))
					throw new Exception("Wrong ip address.");
				else
					ip = value;
			}
		}
		private int port = 1070;
		public int Port
		{
			get { return port; }
			set
			{
				if (value < 1 && value > 65535)
					throw new Exception("Wrong port.");
				else
					port = value;
			}
		}

		private enum Code : uint
		{
			check_command = 4294967295,
			version = 0,
			pasp_download = 4,
			download_nh = 21,
			dir_browse = 23,
			user_flags = 26
		}
		//Construction
		public NETClient()
		{
			Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
			enc = Encoding.GetEncoding(866);
		}
		public NETClient(string ip, int port)
		{
			Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
			enc = Encoding.GetEncoding(866);
			Ip = ip;
			Port = port;
		}


		//Work with socket functions
		public byte[] CreateCode(uint code, byte[] prefix = null, string val = null, byte[] postfix = null)
		{
			var res = new List<byte>();

			return res.ToArray();
		}

		//Support functions


		//Main functions

	}
}
