Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. using System;
  2. using System.Net;
  3. using System.Net.Sockets;
  4.  
  5. namespace demo1
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. IPAddress ia = IPAddress.Parse("127.0.0.1");
  12. IPEndPoint ie = new IPEndPoint(ia, 8000);
  13. Socket socket = new Socket(AddressFamily.InterNetwork,SocketType.Stream, ProtocolType.Tcp);
  14.  
  15. Console.WriteLine("AddressFamily: {0}",socket.AddressFamily);
  16. Console.WriteLine("SocketType: {0}",socket.SocketType);
  17. Console.WriteLine("ProtocolType: {0}",socket.ProtocolType);
  18. Console.WriteLine("Blocking: {0}", socket.Blocking);
  19.  
  20. socket.Blocking = false;
  21.  
  22. Console.WriteLine("new Blocking: {0}",socket.Blocking);
  23. Console.WriteLine("Connected: {0}", socket.Connected);
  24. socket.Bind(ie);
  25.  
  26. IPEndPoint iep = (IPEndPoint)socket.LocalEndPoint;
  27. Console.WriteLine("Local EndPoint: {0}",iep.ToString());
  28. socket.Close();
  29. }
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement