We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

socket.connect errors

rmmarsh
rmmarsh asked
on
Medium Priority
227 Views
Last Modified: 2010-04-16
I have the following piece of code:

            try
            {
                socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                ep = new IPEndPoint(Dns.GetHostEntry(ipAddress).AddressList[0], port);
                socket.Connect(ep);
            }
            catch (Exception ex)
            {
                // doubtfull....
                if (socket != null && socket.Connected)
                    socket.Close();
                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.
Comment
Watch Question

e1v
Commented:
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

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Commented:
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.

Author

Commented:
Don't know... will have to test it and get back to you... sorry...

Author

Commented:
The problem appears to have gone away... hmmmm
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.