Guest User

Untitled

a guest
Mar 21st, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. try {
  2. String ip = "192.168.163.44";
  3.  
  4. int port = 8001;
  5. IPAddress ipAd = IPAddress.Parse(ip);
  6. TcpListener myList = new TcpListener(ipAd, port);
  7. myList.Start();
  8.  
  9. while (true)
  10. {
  11.  
  12. Socket s = myList.AcceptSocket();
  13.  
  14. string url = null;
  15. string[] connection = null;
  16. string msq = null;
  17. byte[] dataByte = null;
  18. int i = 0;
  19. int numConnection = 0;
  20. byte[] readBuffer = new byte[s.ReceiveBufferSize];
  21. List<byte[]> msqList = new List<byte[]>();
  22. do
  23. {
  24. ++i;
  25. readBuffer = new byte[s.ReceiveBufferSize];
  26. int numberOfBytesRead = s.Receive(readBuffer);
  27. msq = null;
  28.  
  29. if (i == 1)
  30. {
  31. numConnection = Int32.Parse(Encoding.ASCII.GetString(TrimEnd(readBuffer)));
  32. urltext.Text = numConnection.ToString();
  33. Debug.WriteLine("recieved: {0}", numConnection);
  34. }
  35.  
  36. } while (i < numConnection);
  37.  
  38.  
  39. s.Close();
  40.  
  41. }
  42. myList.Stop();
  43.  
  44. }
  45. catch (Exception ex)
  46. {
  47. Console.WriteLine("Error..... " + ex.StackTrace);
  48. Console.ReadLine();
  49. }`
  50.  
  51. namespace App2
  52. {
  53. public partial class MainPage : ContentPage
  54. {
  55. public MainPage()
  56. {
  57.  
  58. InitializeComponent();
  59.  
  60. //Here//
  61.  
  62. }
  63. }
  64. }
Add Comment
Please, Sign In to add comment