public void SendFirmware(string path) { if (File.Exists(path)) { using (m_Server = new TftpServer()) { m_Server.OnReadRequest += OnReadRequest; using (m_Client = new UdpClient(new IPEndPoint(IPAddress.Any, LocalPort))) { m_Client.Client.ReceiveTimeout = 2000; m_Path = path; m_TransferHasError = false; m_TransferHasFinished = false; m_Server.Start(); if (!RequestDeviceName() || !ConfigureDeviceForDHCP() || !RequestDeviceIP() || !InitiateDeviceUpdate(path)) { return; } while (!m_TransferHasFinished) { if (m_TransferHasError) { return; } Thread.Sleep(1000); } } } } }
public TFTPServer(IPAddress localAddress, int port, string rootDirectory) { server = new TftpServer(localAddress, port); ServerDirectory = rootDirectory; server.OnReadRequest += Server_OnReadRequest; server.OnWriteRequest += Server_OnWriteRequest; server.Start(); Trace.WriteLine($"Start TFTPD on {localAddress.ToString()}:{port.ToString()}"); Trace.WriteLine($"TFTP root dir: {rootDirectory}"); Trace.Flush(); }
public void run(string dir, ServerForm _form) { form = _form; ServerDirectory = dir; Debug.Write("Server dir " + ServerDirectory); tftpServer = new TftpServer(); { tftpServer.OnReadRequest += new TftpServerEventHandler(server_OnReadRequest); tftpServer.OnWriteRequest += new TftpServerEventHandler(server_OnWriteRequest); tftpServer.Start(); form.Log.Invoke($"Server started!"); } }
public Server() { if (s_instance != null) { throw new Exception("Only a single instance of TFTP Server can be instantiated at a time"); } s_instance = this; m_server = new TftpServer(); m_server.OnReadRequest += server_OnReadRequest; m_server.OnWriteRequest += server_OnWriteRequest; m_server.Start(); }
public static void ResimveSeslerGonder() { ServerDirectory = Environment.CurrentDirectory; Debug.WriteLine("Running TFTP server for directory: " + ServerDirectory); using (var server = new TftpServer()) { server.OnReadRequest += new TftpServerEventHandler(server_OnReadRequest); server.OnWriteRequest += new TftpServerEventHandler(server_OnWriteRequest); server.Start(); } }
public void startTftpServer() { ServerDirectory = Environment.CurrentDirectory + "\\ipxe"; using (var server = new TftpServer()) { server.OnReadRequest += new TftpServerEventHandler(server_OnReadRequest); server.OnWriteRequest += new TftpServerEventHandler(server_OnWriteRequest); server.Start(); Console.WriteLine("Running TFTP server for directory: " + ServerDirectory); while (true) { Thread.Sleep(10000); } } }
static void Main(string[] args) { ServerDirectory = Environment.CurrentDirectory; Console.WriteLine("Running TFTP server for directory: " + ServerDirectory); Console.WriteLine(); Console.WriteLine("Press any key to close the server."); using (var server = new TftpServer()) { server.OnReadRequest += new TftpServerEventHandler(server_OnReadRequest); server.OnWriteRequest += new TftpServerEventHandler(server_OnWriteRequest); server.Start(); Console.Read(); } }
static void Main(string[] args) { ServerDirectory = System.IO.Path.GetTempPath() + "configFiles"; Console.WriteLine("Running TFTP server for directory: " + ServerDirectory); Console.WriteLine(); //Console.WriteLine("Press any key to close the server."); using (var server = new TftpServer()) { server.OnReadRequest += new TftpServerEventHandler(server_OnReadRequest); server.OnWriteRequest += new TftpServerEventHandler(server_OnWriteRequest); server.Start(); while (Console.ReadKey(true).Key != ConsoleKey.Escape) { } } }
public void ClientsReadsFromServer() { using (TftpServer server = new TftpServer(new IPEndPoint(IPAddress.Loopback, 69))) { server.OnReadRequest += new TftpServerEventHandler(server_OnReadRequest); server.Start(); TftpClient client = new TftpClient(new IPEndPoint(IPAddress.Loopback, 69)); using (ITftpTransfer transfer = client.Download("Demo File")) { MemoryStream ms = new MemoryStream(); transfer.OnFinished += new TftpEventHandler(transfer_OnFinished); transfer.Start(ms); Thread.Sleep(500); Assert.IsTrue(TransferHasFinished); } } }
public void Start() { _tftpServer.Start(); }
private void main_Load(object sender, EventArgs e) { server.Start(); }