Home   |   QuickStart Welcome   |   ASP.NET   |   Web Services   |   How Do I...?   
  |   I want my samples in...      

How Do I...? Common Tasks QuickStart Tutorial

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

VB DateTimeServer.exe
View Source
[This sample can be found at C:\DevFusion.Data\legacy\quickstart.developerfusion.co.uk\QuickStart\howto\samples\net\TCPUDP\]



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