473,418 Members | 2,028 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,418 software developers and data experts.

Know Transfer Rate

Bob
Hi.
I'm developed a simple Transfer File program just to test the NetworkStream
class. I want to know how can i get the transfer rate speed.
Does someone know how to do it? And... what's the size limit for the
transfer buffer? I set the buffer size to 1MB. It's ok? This is the code:

private void TransferFile(Socket clientConnection, string fileName)
{
NetworkStream ClientBridge;
FileStream FileToTransfer;
byte[] FileBuffer;
long FileSize;
long BytesTransfered;
int BytesReaded;
string PercentTransfered;
ListViewItem ClientItem;
try
{
FileBuffer = new byte[122880];
FileToTransfer = File.Open(SHARED_DIRECTORY +
fileName,FileMode.Open,FileAccess.Read);
FileSize = FileToTransfer.Length;
BytesTransfered = 0;
ClientItem =
GetClientItem(((IPEndPoint)clientConnection.Remote EndPoint).Address.ToString
());
ClientBridge = new NetworkStream(clientConnection);
ClientItem.SubItems[1].Text = "Yes";
while(BytesTransfered < FileSize)
{
BytesReaded =
FileToTransfer.Read(FileBuffer,0,FileBuffer.Length );
ClientBridge.Write(FileBuffer,0,BytesReaded);
BytesTransfered = BytesTransfered + BytesReaded;
PercentTransfered = (((double)BytesTransfered * 100) / (double)
FileSize).ToString();
ClientItem.SubItems[2].Text = PercentTransfered + " %";
}
FileToTransfer.Flush();
ClientBridge.Flush();
FileToTransfer.Close();
ClientItem.SubItems[1].Text = "No";
}
catch(Exception ex)
{
throw ex;
}
}

Thanks Advanced.
Nov 17 '05 #1
0 1211

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: None | last post by:
I'm using the HttpWebRequest/Response methods and I'm trying to figure out how to calculate the effective transfer rare the file is being received at (like you see in IE when you download...
2
by: mscdex | last post by:
I have a server application that accepts file transfers (utilitzing tcplistener) and was wondering how I would efficiently go about determining the calculate transfer rate while I am transferring...
1
by: whatazor | last post by:
Hi, how can I calulate transfer rate to a host , without using a file ? can ping module (written by Jeremy Hylton) be useful ?
0
by: nuttynibbles | last post by:
hi, im creating a mobile apps whereby if i transfer a file from a PC to a folder directory in the windows mobile phone, it will detect and fire an event? for example, rename each file that is...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.