Netduino home hardware projects downloads community

Jump to content

The Netduino forums have been replaced by new forums at This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.

How do I read a network stream ?

Sockets Network

  • Please log in to reply
1 reply to this topic

#1 bgreer5050



  • Members
  • PipPip
  • 28 posts

Posted 22 April 2015 - 04:46 PM

I copied an example of how to use a socket and a stream to send a request to a server below.  It was from Nicky and there is a reference to the link at the end of this post.  How can I read the stream returned from the server in this example ?  What type of conversion can I expect to have to make so the response is human readable ?

public static void InStateToServer(int port)
   IPHostEntry host = Dns.GetHostEntry("");
   IPEndPoint endPoint = new IPEndPoint(host.AddressList[0], 80);

   using (Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))

      using (NetworkStream ns = new NetworkStream(socket))
         byte[] bytes = System.Text.Encoding.UTF8.GetBytes("GET /decoder_control.cgi?command=" + port + "&user=admin&pwd=abc HTTP/1.1\r\n");
         ns.Write(bytes, 0, bytes.Length);

Code From Nicky

#2 KiwiDev


    Advanced Member

  • Members
  • PipPipPip
  • 100 posts
  • LocationNew Zealand

Posted 23 April 2015 - 09:28 AM



If your doing an HTTP request it is most probably easier\simpler to use the functionality in System.http.


See bottom of this post for sample code.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.