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 client with TCPClient?

This sample illustrates using the TCPClient class to create a DateTime program.

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.

The application firsts creates a TCPClient object with the default constructor. Next, the hostname that was specified at the command line is resolved into an IP address with the static class DNS. Next, the Connect method is called and the TCPClient connects to the server on port 13.

The GetStream method is next called and a Stream object is returned that represents the data returned by the server. This data is read from the Stream object with the Read method. The byte array that the Read method returns is turned into a string and displayed.


VB DateTimeClient.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.