I want to transfer n number of binary files from a server
to a client one by one.
I am using TcpListener and TcpClient.
Any suggestions?
mE
TcpClient tc = tcpListener.AcceptTcpClient();
NetworkStream ns = tc.GetStream();
IAsyncResult iar = ns.BeginWrite(bytebuffer, offset, size, null, null);
//do some other processing
try
{
ns.EndWrite(IAsyncResult);
}
catch
{
//Networkerrors go here
}
other side:
TcpClient tc = new TcpClient();
tc.Connect(.......)
Networkstream ns = tc.GetStream();
IAsyncResult iar = ns.BeginRead(......)
//do some other processing
try
{
ns.EndRead(IAsyncResult);
}
catch
{
//Networkerrors go here
}
of course you could also use AsyncCallbacks so that you don't have
explicitely to wait for the end of the send/receive methods.