Encoding ASCII = Encoding.ASCII; string AtCmd = "AT%MEAS=\"2\""; Byte[] ByteGet = ASCII.GetBytes(AtCmd); Byte[] RecvBytes = new Byte[1024]; String strRetPage = null; // IPAddress and IPEndPoint represent the endpoint that will // receive the request. // Get the first IPAddress in the list using DNS. string server = "127.0.0.1"; IPAddress hostadd = Dns.Resolve(server).AddressList[0]; IPEndPoint EPhost = new IPEndPoint(hostadd, 9999); //Creates the Socket for sending data over TCP. Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Stream,ProtocolType.Tcp); // Connects to the host using IPEndPoint. s.Connect(EPhost); if (!s.Connected) { strRetPage = "Unable to connect to host"; // return strRetPage; } // Sends the GET text to the host. if (s.Send(ByteGet, ByteGet.Length, SocketFlags.None) == ByteGet.Length) { // Receives the page, looping until all bytes are received Int32 bytes = s.Receive(RecvBytes, RecvBytes.Length, 0); ---> Here it gets stuck while (bytes > 0) { bytes = s.Receive(RecvBytes, RecvBytes.Length, SocketFlags.None); strRetPage = strRetPage + ASCII.GetString(RecvBytes, 0, bytes); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)