Welcome   |  ASP.NET   |  Web Services   |  How Do I...?   |  Class Browser  | WPF Quick Starts
  |   I want my samples in...   

How Do I...? Common Tasks QuickStart Tutorial

Go To...

How Do I...Make a DateTime server with TCPListener?

This sample illustrates how to use the TCPListener class to create a DateTime server program.

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.

The application firsts creates a TCPListener object with the constructor that specifies that the Listener should handle all incoming requests on port 13. Next, it goes into a loop and continues to listen for incoming connections. The connections are then accepted with the Accept method, and the socket returned is used to Send the current date and time.

The Receive method could be called to get data from the client, but that method is ignored, as the Date and Time protocol does not need any information that is sent from the client, but automatically returns the information.

Example

C# DateTimeServer.exe
View Source

[This sample can be found at M:\web\users\sites\AspnetQuickStart\v2.0\QuickStart\howto\samples\net\TCPUDP\
To build this sample, open the SDK command prompt and navigate to the above path. Build the sample using the build tool msbuild passing the solution file as the first parameter: msbuild mySample.sln. The compiled executable will be found in the sub directory \bin directory.]




Microsoft .NET Framework SDK QuickStart Tutorials Version 2.0
Copyright � 2005 Microsoft Corporation. All rights reserved.


Hosted by MaximumASP | Found a broken link? | Contact Us | Terms and conditions | Privacy Policy | Advertise with us
� 2000 - 2010  Mindcracker LLC. All Rights Reserved