home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 40 / IOPROG_40.ISO / SOFT / NETFrameworkSDK.exe / comsdk.cab / samples.exe / QuickStart / howto / doc / TCPUDP / dateTimeClient.aspx < prev    next >
Encoding:
Text File  |  2000-06-11  |  2.0 KB  |  49 lines

  1. <%@ Register TagPrefix="Acme" TagName="SourceRef" Src="/quickstart/util/SrcRef.aspx"%>
  2.  
  3. <!-- #include virtual="/quickstart/howto/include/header.inc" -->
  4.  
  5. <script language="C#" runat="server">
  6.  
  7.     public void Page_Load(Object sender, EventArgs E) 
  8.     {
  9.         // shell the explorer to a directory
  10.         Ref.RunSample = Server.MapPath("/quickstart/howto/samples/net/TCPUDP");
  11.  
  12.         // run an aspx page directly
  13.         // Ref.RunSample = "/quickstart/howto/samples/BaseDataTypes/Sort/Sort.aspx";
  14.  
  15.         Ref.ViewSource = "/quickstart/howto/samples/net/TCPUDP/dateTimeClient.src";
  16.         Ref.Icon = "/quickstart/images/genicon.gif";
  17.         Ref.Caption = "dateTimeClient.exe";
  18.     }
  19.  
  20. </script>
  21.  
  22. <h4>How Do I...Make a DateTime client with TCPClient?</h4>
  23.  
  24. <div class="indent" style="width:660"></div>
  25. <P>
  26. This sample illustrates using the TCPClient class to create a DateTime program.
  27. </p><P>
  28. This application acts as a client for the standard Date and Time protocol. This protocol works on port 13, and responds to any TCP connections to that port with the current date and time.
  29. </P>
  30. <P>
  31. The application firsts creates a <B>TCPClient</B> object with the default constructor. Next, the hostname that was specified at the command line is resolved into an IP address with the statis class <B>DNS</B>. Next, the <B>Connect</B> method is called and the TCPClient connects to the server on port 13.
  32. </P>
  33. <P>
  34. The <B>GetStream</B> method is next called and a <B>Stream</B> object is returned that represents the data returned by the server. This data is read from the <B>Stream</B> object with the read method, and the byte array that the read function returns is turned into a string, and displayed.
  35. </P>
  36. <h4>Example</h4>
  37.  
  38. <Acme:SourceRef id="Ref" runat="server" />
  39.  
  40. <h4>Source Code</h4>
  41.  
  42. <div class="code">
  43. <xmp>
  44. <!-- #include virtual="/quickstart/howto/samples/net/TCPUDP/dateTimeClient.cs" -->
  45. </xmp>
  46. </div>
  47.  
  48. <!-- #include virtual="/quickstart/howto/include/footer.inc" -->
  49.