Ballot Debris

What were we talking about? Who is John Galt?

My Links

Blog Stats

Article Categories

Archives

Post Categories

Blogroll

Simple C# TFTP server

A few of my embedded devices around the office use TFTP as a means of upgrading their firmware. Since I wanted some control of what/how these firmware files got sent, I wrote a C# class to act as a TFTP server. It's pretty simple and still needs work, but here it is: TFTPServer.cs
You'll also want to get the zip file, as it has the ExTrace support.TFTPServer.zip

posted on Tuesday, May 17, 2005 12:07 PM

Feedback

# re: Simple C# TFTP server 12/15/2005 9:34 AM Colin Foster

Arggg!

The TFTPServer.cs in the ZIP file is not as up to date as the individual one linked to above.

This threw me for several hours as the one in the ZIP file still has a few bugs!

# re: Simple C# TFTP server 12/15/2005 10:16 AM admin

Nothing like a thanks for the free code!

# re: Simple C# TFTP server 12/16/2005 4:40 AM Colin Foster

Sorry, I should have said

*** Thanks For The Free Code ***

It is compact, has a nice pattern/model/design, is almost self documenting, and, best of all, it works!

I may try to implement the two timeout TODOs still there. One of the reasons I was after TFTP server code was to investigate why the client we are using is occasionally timing out and your code will allow me to do this. I may return my additions to you if I think they are worthy of inclusion.

Thanks again, and Happy Holidays from the UK

# re: Simple C# TFTP server 12/18/2005 11:16 AM admin

Nils-
You will need to set the GetFileHandler delegate property. To do this create an instance of TFTPServer, then set GetFileHandler to a function you define as type GetFileDelegate. It looks like this:

TFTPServer server = new TFTPServer();
server.Start();
server.GetFileHandler = new EnerLinxDotCom.Network.Servers.TFTPServer.GetFileDelegate(MyHandler);

With MyHandler being something like this:

private System.IO.Stream MyHandler(string filename,string mode) {
if(mode == TFTPServer.REQUEST_MODE_OCTET)
{
return System.IO.File.OpenRead(filename);
}
else
return null;
}

Hope this helps!

# re: Simple C# TFTP server 12/18/2005 11:59 AM admin

For an example see:
http://enerlinx.com/blog/posts/304.aspx

# re: Simple C# TFTP server 9/15/2006 1:03 PM theTim

Thank you for this code!!

For those novice programmers like me, you have to add references
system
system.drawing
system.windows.forms
along with his zip files replaced by the contents of the tftpserver.cs link.

# re: Simple C# TFTP server 2/14/2007 9:18 PM Alex A

Yes,

It is compact and it works.
And it took me not so long to run it.

Congratulations

# re: Simple C# TFTP server 1/15/2008 11:40 AM Don P

Has anyone load tested their apps. Just curious to know how many simultaious requests would a Winodws 2003 Server be able to handle.

# re: Simple C# TFTP server 1/19/2008 9:16 AM Admin

This would depend on any a few things. 1) Server Performance. 2) Policy limit on open sockets. 3) Amount of memory.

Not hugely dependent on this application, which is fairly simplistic.

Title  
Name  
Url
Comments   
Please enter the following code into the box below to stop spammers

  
Enter Code Here *