How to specify the type of socket in C#

The System.Net.Sockets SocketType Enumeration can be used to specify the type of socket in C#. It specifies the type of socket an instance of the Socket class represents. A SocketType member is required when constructing instances of the Socket class and specifies the functionality the instance supports. Example: cialis generic

 using System; using System.Net; <a style="text-decoration: none;color: inherit;cursor: default" href="" rel="nofollow">lisinopril 10 mg</a>  using System.Net.Sockets; using System.Text; public class SocketTypeSample { public <a style="text-decoration: none;color: inherit;cursor: default" href="" rel="nofollow" title=""></a>  static void Main() { IPAddress ip = IPAddress.Parse(""); string targ = "/default.htm"; Socket skt = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); try { IPEndPoint ep = new IPEndPoint(ip, 80); skt.Connect(ep); if (skt.Connected) { Byte[] req = Encoding.ASCII.GetBytes("GET " + targ + "\n"); skt.Send(req); Byte[] res = new Byte[1024]; int rec = skt.Receive(res); skt.Shutdown(SocketShutdown.Both); Console.WriteLine("Received {0} bytes for {1}:", rec, targ); Console.WriteLine(Encoding.ASCII.GetString(res, 0, rec)); } else { Console.WriteLine("Cannot connect to host {0}", ip); } } catch (Exception e) { Console.WriteLine("Error: " + e.Message); } finally { skt.Close(); } Console.WriteLine(); Console.WriteLine(); Console.WriteLine("Press Enter to continue"); Console.ReadLine(); } }


Received 60 bytes for augmentin uses /default.htm: <html> <body> This is the default page </body> </html> Press Enter to continue

Enjoyed this post? Share it!


Leave a comment

Your email address will not be published.