Sunday 27 March 2016

How to check if Email Id exists in C# using TCP Client : Code with Explanation

Check if Email Id exists in c# using TCPClient


In my last post, I shared code for checking if email Id exists or not using Sockets.

In this post, I will be using TCPClient to interact with Network Stream and reading the response returned by it using Stream Reader , and deciding on the email existence through the response code returned by host on our Network Stream.



  • TCPClient : Just like Socket, it provides methods for connecting, sending and receiving stream data over a network. We have created TCPClient object using host name and port number of host. The constructor will itself attempt connection for TCPClient.
  • GetStream() : Method to obtain NetworkStream. We can use Write and Read methods to send and receive response with the remote host.
It is no different from our previous approach. Using Sockets and TCPClient are doing the same thing, and as TCPClient is a wrapper around the Socket class, so there is no much performance difference.
Developer can opt for any approach.

In the next post :
  • Sending Activation Link email to registered user



No comments:

Post a Comment