Socket.Connect questions

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);
socket.Connect(remoteEP);

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");
socket.Send(ehlo);
socket.Send(quit);
socket.Close();      
Console.WriteLine("Disconnected! \r\n");

Does this look ok?

Thanks for looking
dave
LVL 2
KaiserSoseAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

dunglaCommented:
Can you show me the socker definition?

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
KaiserSoseAuthor Commented:
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.

dave
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.

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.