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 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
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