We help IT Professionals succeed at work.
Get Started

WCF, How to capture the client disconnection at the server side.

parabellum
parabellum asked
on
1,206 Views
Last Modified: 2012-06-21

Hello,

I  have written a file server/client using WCF (net.tcp) .  Here is my problem:

While a client is uploading a file to the server, when I pull the ethernet cable at the client side my client gets an exception.(Which is obvious since i have disconnected the client from server).

 Below is the Upload file function. The problem is i  am not getting any exception  at the server side at all. So i can not detect that there is a problem with the client side.

How can i understand that the file transfer is not complete ?

 


public string UploadToServer(Stream stream)
{
  FileStream fStream=File.Open(.....);

 try
{
  while(stream.Read(fileUploadBuffer,0,bufferLen)>0)
   fStream.Write(fileUploadBuffer,0,....)

  return "OK";
}
 catch (Exception ex)
{
  // Log operations here.
  return "ERROR";
}


}

Open in new window

Comment
Watch Question
CEO @ Arkro IT
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 2 Answers and 5 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE