C# Netwotk
C# Netwotk
C# Network
™
Programming
Richard Blum
C# Network
™
Programming
Richard Blum
Copyright © 2003 SYBEX Inc., 1151 Marina Village Parkway, Alameda, CA 94501. World rights reserved. No part of this publication may
be stored in a retrieval system, transmitted, or reproduced in any way, including but not limited to photocopy, photograph, magnetic, or
other record, without the prior agreement and written permission of the publisher.
ISBN: 0-7821-4176-5
SYBEX and the SYBEX logo are either registered trademarks or trademarks of SYBEX Inc. in the United States and/or other countries.
Screen reproductions produced with FullShot 99. FullShot 99 © 1991-1999 Inbit Incorporated. All rights reserved.
FullShot is a trademark of Inbit Incorporated.
Internet screen shot(s) using Microsoft Internet Explorer Version 6 reprinted by permission from Microsoft Corporation.
TRADEMARKS: SYBEX has attempted throughout this book to distinguish proprietary trademarks from descriptive terms by following
the capitalization style used by the manufacturer.
The author and publisher have made their best efforts to prepare this book, and the content is based upon final release software whenever
possible. Portions of the manuscript may be based upon pre-release versions supplied by software manufacturer(s). The author and the pub-
lisher make no representation or warranties of any kind with regard to the completeness or accuracy of the contents herein and accept no
liability of any kind including but not limited to performance, merchantability, fitness for any particular purpose, or any losses or damages
of any kind caused or alleged to be caused directly or indirectly from this book.
10 9 8 7 6 5 4 3 2 1
4176FM 11/6/02 3:14 PM Page iii
SOFTWARE LICENSE AGREEMENT: TERMS using the information provided in the appropriate read.me files or
AND CONDITIONS listed elsewhere on the media.
The media and/or any online materials accompanying this book
Should the manufacturer(s) or other Owner(s) cease to offer sup-
that are available now or in the future contain programs and/or
port or decline to honor any offer, SYBEX bears no responsibility.
text files (the “Software”) to be used in connection with the book.
This notice concerning support for the Software is provided for
SYBEX hereby grants to you a license to use the Software, subject
your information only. SYBEX is not the agent or principal of the
to the terms that follow. Your purchase, acceptance, or use of the
Owner(s), and SYBEX is in no way responsible for providing any
Software will constitute your acceptance of such terms.
support for the Software, nor is it liable or responsible for any sup-
port provided, or not provided, by the Owner(s).
The Software compilation is the property of SYBEX unless other-
wise indicated and is protected by copyright to SYBEX or other
Disclaimer
copyright owner(s) as indicated in the media files (the “Owner(s)”).
SYBEX makes no warranty or representation, either expressed or
You are hereby granted a single-user license to use the Software
implied, with respect to the Software or its contents, quality, per-
for your personal, noncommercial use only. You may not repro-
formance, merchantability, or fitness for a particular purpose. In
duce, sell, distribute, publish, circulate, or commercially exploit
no event will SYBEX, its distributors, or dealers be liable to you
the Software, or any portion thereof, without the written consent
or any other party for direct, indirect, special, incidental, conse-
of SYBEX and the specific copyright owner(s) of any component
quential, or other damages arising out of the use of or inability to
software included on this media.
use the Software or its contents even if advised of the possibility of
such damage. In the event that the Software includes an online
In the event that the Software or components include specific
update feature, SYBEX further disclaims any obligation to provide
license requirements or end-user agreements, statements of
this feature for any specific duration other than the initial posting.
condition, disclaimers, limitations or warranties (“End-User
License”), those End-User Licenses supersede the terms and
The exclusion of implied warranties is not permitted by some
conditions herein as to that particular Software component. Your
states. Therefore, the above exclusion may not apply to you.
purchase, acceptance, or use of the Software will constitute your
This warranty provides you with specific legal rights; there may
acceptance of such End-User Licenses.
be other rights that you may have that vary from state to state.
The pricing of the book with the Software by SYBEX reflects
By purchase, use or acceptance of the Software you further agree
the allocation of risk and limitations on liability contained in this
to comply with all export laws and regulations of the United States
agreement of Terms and Conditions.
as such laws and regulations may exist from time to time.
Shareware Distribution
Reusable Code in This Book
This Software may contain various programs that are distributed as
The author(s) created reusable code in this publication expressly
shareware. Copyright laws apply to both shareware and ordinary
for reuse by readers. Sybex grants readers limited permission to
commercial software, and the copyright Owner(s) retains all rights. If
reuse the code found in this publication, and available for down-
you try a shareware program and continue using it, you are expected
load from our website so long as the author(s) are attributed in
to register it. Individual programs differ on details of trial periods,
any application containing the reusable code and the code itself is
registration, and payment. Please observe the requirements stated in
never distributed, posted online by electronic transmission, sold,
appropriate files.
or commercially exploited as a stand-alone product.
Copy Protection
Software Support
The Software in whole or in part may or may not be copy-protected
Components of the supplemental Software and any offers associ-
or encrypted. However, in all cases, reselling or redistributing these
ated with them may be supported by the specific Owner(s) of that
files without authorization is expressly forbidden except as specifi-
material, but they are not supported by SYBEX. Information
cally provided for by the Owner(s) therein.
regarding any available support may be obtained from the Owner(s)
4176FM 11/6/02 3:14 PM Page iv
Acknowledgments
irst, all honor, glory, and praise goes to God, who through His Son, all things are possible,
F and who gives us the gift of eternal life.
I would like to thank all the great people at Sybex for their help, guidance, and profes-
sionalism. Thanks to Denise Santoro Lincoln, the Acquisitions Editor, for offering me the
opportunity to write this book. Also, thanks to Carol Henry, the Developmental Editor,
for all her work guiding this book along and helping make my paragraphs make sense.
Many thanks to Sally Engelfried, the Copy Editor, for turning my poor grammar into
perfect sentences, and to Dan Frumin, the Technical Editor, for going above and beyond
the call of duty fixing my programs and pointing out my technical blunders. Also, thanks
to Carole McClendon at Waterside Productions for her help in arranging this book for me.
Finally, I would like to thank my parents, Mike and Joyce Blum, for their dedication and sup-
port, and my wife Barbara and daughters Katie Jane and Jessica for their faith, love, and under-
standing, especially while I was writing this book.
4176FM 11/6/02 3:14 PM Page vi
Contents at a Glance
Introduction xix
Index 623
4176FM 11/6/02 3:14 PM Page viii
4176FM 11/6/02 3:14 PM Page ix
Contents
Introduction xix
x Contents
Contents xi
xii Contents
Contents xiii