home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 40 / IOPROG_40.ISO / SOFT / NETFrameworkSDK.exe / comsdk.cab / samples.exe / QuickStart / howto / doc / TCPUDP / dateTimeServer.aspx < prev   
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/dateTimeServer.src";
  16.         Ref.Icon = "/quickstart/images/genicon.gif";
  17.         Ref.Caption = "dateTimeServer.exe";
  18.     }
  19.  
  20. </script>
  21.  
  22. <h4>How Do I...Make a DateTime server with TCPListener?</h4>
  23.  
  24. <div class="indent" style="width:660"></div>
  25. <P>
  26. This sample illustrates using the TCPListener class to create a DateTime server program.
  27. <P>
  28. This application acts as a Server 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. The application firsts creates a <B>TCPListener</B> object with the constructor that specifies that the Listener should handle all requests incoming on Port 13. Next, it goes into a loop and continues to listen for incoming connections. The connections are then accepted with the <B>Accept</B> method, and the  Socket  returned is used to <B>Send</B> the current date and time. 
  31. </P>
  32. <P>
  33. The <B>Receive</B> method could be called to get data from the client, but that method is ignored, as the Date and Time protocol doesn't need any information that is sent from the client, but automatically returns the information.
  34. </P>
  35.  
  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/dateTimeServer.cs" -->
  45. </xmp>
  46. </div>
  47.  
  48. <!-- #include virtual="/quickstart/howto/include/footer.inc" -->
  49.