Advertisement
Guest User

Untitled

a guest
Mar 31st, 2012
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.84 KB | None | 0 0
  1.  private void initSockets()
  2.         {
  3.             System.Net.Sockets.TcpClient clientSocket = new System.Net.Sockets.TcpClient();
  4.        
  5.             IPEndPoint endPoint = new IPEndPoint(IPAddress.Parse("192.168.1.4"), 18041);
  6.             Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
  7.             byte[] data = new byte[1024];
  8.             data = Encoding.ASCII.GetBytes("TESTING");
  9.             clientSocket.Connect("192.168.1.4", 18042);
  10.             //sock.Connect(endPoint);
  11.             //155.42.86.237
  12.             sock.Send(data, data.Length, SocketFlags.None);
  13.             while (true)
  14.             {
  15.                
  16.                 int receivedDataLength = sock.Receive(data);
  17.                 string stringData = Encoding.ASCII.GetString(data, 0, receivedDataLength);
  18.             }
  19.  
  20.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement