Question

I am currently writing a system logging program which sends different logs via ftp. The Problem I am facing is that my program should constantly check if the connection is being used before and during it's upload in order to stop sending packets if a different program wants to use the connection.

I actually found this link helping me measure the speed of the connection, but I think I can only use the latter in order to discover if the something is already being streamed. After reading the library entry on System.Net.NetworkInformation, checking various Network Statistics and states wasn't a problem either. As stated beforehand my only problem is checking if some other program wants to send something.

As you can probably tell from the question, I am very new to this topic and a fairly junior programmer. I have been reading up on the System.Net.NetworkInformation Namespace library and facilitating it's various classes, methods and delegates. I have the feeling that I am on the right track, but just not getting there. Anyone got a push in the right direction?

Thank you.

Was it helpful?

Solution

I ended up using the System.Net.NetworkInformation library and it's methods.

The methods GetIsNetworkAvailable(), NetworkChange.NetworkAvailabilityChanged Eventhandler and the TcpStatistics helped me gather information on the connection. MSDN and the reference is a great guide in using the foregone mentionend methods and I basically used the examples with slight modifications to suit my needs.

msdn NetworkInformation: http://msdn.microsoft.com/de-de/library/system.net.networkinformation.aspx

The GetIsNetworkAvailable is pretty straight forward returns boolean value on connection being up or down.

Networkchange.NetworkAvailabilityChanged triggers an event on connection loss or reconnection. See the msdn link above for an excellent and very usuable example on it's usage.

And the TcpStatistics return information on how many connections have been accepted, initiated, errors received, failed connections, connection resets and more. These were the five I used so far to evaluate the connection.

I realized that you do not really need any more to monitor the connection efficiently. Maybe the method NetworkInterface.GetAllNetworkInterfaces() can help finding out which Networkadapter is sending the data and should be monitored.

I now understand the comments of Peter Ritchie to my question. FTP transmission runs extremely well and the protocol handles the transmission of the files flawlessly and no problems have arisen up until now in streaming the log files. In 4 weeks of testing I have received the logging data constantly.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top