Socket.Connect questions

Posted on 2004-11-24
Last Modified: 2010-04-15
I am just writing a simple console app to make sure our servers are accepting connections.

When I use

System.Net.IPAddress ipAddress = System.Net.IPAddress.Parse(TEST_SERVER);
System.Net.EndPoint remoteEP = new System.Net.IPEndPoint(ipAddress, SERVER_PORT);

to connect to a server on port 25, should I get the normal response messages that you get when you telnet to port 25?

Also, I don't want to leave the socket hanging open, so I am using this to close the connection:

byte[] ehlo = Encoding.ASCII.GetBytes("EHLO");
byte[] quit = Encoding.ASCII.GetBytes("QUIT");
Console.WriteLine("Disconnected! \r\n");

Does this look ok?

Thanks for looking
Question by:KaiserSose
    LVL 13

    Accepted Solution

    Can you show me the socker definition?

    When you run the code, did you received any exception with error code 10043?
    LVL 2

    Author Comment

    I had the socket declaration outside of the wrong loop.  :)   It was trying to call a disposed object.  I got it working, thanks for the help.


    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
    Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now