Testing connectivity using Socket.Poll() timeout issue

Mar 4, 2015 at 6:03 PM
Edited Mar 4, 2015 at 6:04 PM
Hi

I spawn 3 worker threads on a console application where each thread has its own ftp client like such...

ftpPool.TaskToPerform = (job, index) =>
        {

                try
                {
                    using (FtpClient conn = new FtpClient())
                    {
                        conn.Host = this.ftp;
                        conn.Credentials = new NetworkCredential(this.ftpUsername, this.ftpPassword);

                        using (FileStream fileStream = new FileStream(Path.Combine(this.dropFolder, job.Name), FileMode.Create))
                        {
                            using (Stream istream = conn.OpenRead(string.Format("{0}", job.Name)))
                            {

                                byte[] b = new byte[8192];
                                int read = 0;

                                try
                                {
                                    while ((read = istream.Read(b, 0, b.Length)) > 0)
                                    {
                                        fileStream.Write(b, 0, read);
                                    }
                                }
                                finally
                                {
                                    istream.Close();
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                  Console.WriteLine(ex.ToString());
                }
        };
I then wait for threads to complete. Sometimes it works fine but sometimes (for larger files 200mb+) i get the following output

TEXT

Ive tried changing timeout settings on the conn object but nothing seems to help.

Any help is appreciated

Thanks!