Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 174
  • Last Modified:

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
0
KaiserSose
Asked:
KaiserSose
1 Solution
 
dunglaCommented:
Can you show me the socker definition?

When you run the code, did you received any exception with error code 10043?
0
 
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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now