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.
Example
C# DateTimeClient.exe
[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.
|