Advertisement
Guest User

Untitled

a guest
Jul 5th, 2015
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Net.Sockets;
  6. using System.Net;
  7.  
  8. namespace ConsoleApplication1
  9. {
  10. class Program
  11. {
  12. static void Main(string[] args)
  13. {
  14. Socket serverSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP);
  15. Socket clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP);
  16. Socket internalSocket;
  17. byte[] recBuffer = new byte[256];
  18.  
  19. serverSocket.Bind(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 1024));
  20. serverSocket.Listen(1);
  21. clientSocket.Connect("127.0.0.1", 1024);
  22. internalSocket = serverSocket.Accept();
  23. clientSocket.Send(ASCIIEncoding.ASCII.GetBytes("Hello world!"));
  24. internalSocket.Receive(recBuffer);
  25. Console.WriteLine(ASCIIEncoding.ASCII.GetString(recBuffer));
  26.  
  27. Console.Read();
  28. }
  29. }
  30. }
  31.  
  32.  
  33.  
  34. Oczywiście przykład był w jednej a
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement