socket.connect errors

I have the following piece of code:

                socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                ep = new IPEndPoint(Dns.GetHostEntry(ipAddress).AddressList[0], port);
            catch (Exception ex)
                // doubtfull....
                if (socket != null && socket.Connected)
                throw new FtpException("Can't connect to remote server", ex.Message);

When my conenction to the internet is busy, such as when downloading, the code above throws the exception.  Is there anything I can do to remedy this?  try again?  different port?  I don't know that much about sockets, so I'm at a loss here.
Who is Participating?
What is the exception message you get?
There are several exceptions that could be thrown when calling Connect, so the exception type and message would be helpful.
What kind of Exception are you getting, what is it saying and who is throwing it?
Both Dns.GetHostEntry and socket.Connect can throw exceptions so you have to take a look at the exception you are catching
rmmarshAuthor Commented:
Don't know... will have to test it and get back to you... sorry...
rmmarshAuthor Commented:
The problem appears to have gone away... hmmmm
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.