delphi - the tomes of delphi - basic 32-bit communications programming

577 772 0
delphi - the tomes of delphi - basic 32-bit communications programming

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

TEAMFLY Team-Fly ® The Tomes of Delphi: Basic 32-Bit Communications Programming Alan C. Moore and John C. Penman Wordware Publishing, Inc. Library of Congress Cataloging-in-Publication Data Moore, Alan C., 1943 The Tomes of Delphi : basic 32-bit communications programming / by Alan C. Moore and John C. Penman. p. cm. Includes bibliographical references and index. ISBN 1-55622-752-3 (paperback) 1. Computer software—Development. 2. Delphi (Computer file). 3. Telecommunication systems. I. Penman, John C. II. Title. QA76.76.D47 M665 2002 005.1 dc21 2002011 CIP © 2003, Wordware Publishing, Inc. All Rights Reserved 2320 Los Rios Boulevard Plano, Texas 75074 No part of this book may be reproduced in any form or by any means without permission in writing from Wordware Publishing, Inc. Printed in the United States of America ISBN 1-55622-752-3 10987654321 0210 Delphi is a registered trademark of Borland Software Corporation in the United States and other countries. Other products mentioned are used for identification purposes only and may be trademarks of their respective companies. All inquiries for volume purchases of this book should be addressed to Wordware Publishing, Inc., at the above address. Telephone inquiries may be made by calling: (972) 423-0090 Dedications To Ann, with all my love. Alan C. Moore To the memory of my dear mum, Marie Chisholm Penman, who passed away on March 11, 2001. John C. Penman iii Contents Acknowledgments xiv Introduction xvii Part I: Winsock Chapter 1: The Winsock API 3 Introduction 3 In the Beginning 3 Network Protocols 5 The OSI Network Model 1 6 Before Winsock 7 Evolution of Winsock 8 The Winsock Architecture 9 Winsock 1.1 9 Winsock 2 10 New Features of Winsock 11 Multiple Protocol Support 11 Name Space Independence 11 Scatter and Gather 11 Overlapped I/O 11 Quality of Service 11 Multipoint and Multicast 12 Conditional Acceptance 12 Connect and Disconnect Data 12 Socket Sharing 12 Protocol-specific Addition 12 Socket Groups 12 Summary 13 Chapter 2: Winsock Fundamentals 15 Starting and Closing Winsock 15 function WSAStartup 16 function WSACleanup 19 Handling Winsock Errors 22 Errorsanderrors 23 function WSAGetLastError 24 procedure WSASetLastError 25 v The Many Faces of the Winsock DLL 27 Summary 28 Chapter 3: Winsock 1.1 Resolution 29 Translation Functions 30 function htonl 31 function htons 32 function ntohl 32 function ntohs 33 Miscellaneous Conversion Functions 34 function inet_addr 34 function inet_ntoa 35 Resolution 37 Resolving Using a HOSTS file 38 Resolving Using DNS 39 Resolving Using a Local Database File with DNS 40 Blocking and Asynchronous Resolution 40 Host Resolution 42 function gethostbyaddr 42 function gethostbyname 45 function gethostname 47 function WSAAsyncGetHostByName 48 function WSAAsyncGetHostByAddr 54 Service Resolution 55 function getservbyname 55 function getservbyport 58 function WSAAsyncGetServByName 60 function WSAAsyncGetServByPort 61 Protocol Resolution 62 function getprotobyname 62 function getprotobynumber 64 function WSAAsyncGetProtoByName 66 function WSAAsyncGetProtoByNumber 67 Canceling an Outstanding Asynchronous Call 68 function WSACancelAsyncRequest 68 Summary 69 Chapter 4: Winsock 2 Resolution 71 Translation Functions 71 function WSAHtonl 71 function WSAHtons 74 function WSANtohl 74 function WSANtohs 75 Address and String Conversion Functions 76 function WSAAddressToString 76 vi Contents function WSAStringToAddress 78 Enumerating Network Protocols 79 function WSAEnumProtocols 86 Name Space Resolution and Registration 87 Enumerating Name Spaces 88 function WSAEnumNameSpaceProviders 89 Registering a Service 91 function WSAInstallServiceClass 95 function WSASetService 102 function WSARemoveServiceClass 102 Service Queries 103 function WSALookupServiceBegin 105 function WSALookupServiceNext 109 WSALookupServiceEnd 112 Helper Functions 112 function WSAGetServiceClassInfo 112 function WSAGetServiceClassNameByClassId 113 Functions for the Future 115 Making Your Winsock Applications Agnostic 116 function getaddrinfo 119 procedure freeaddrinfo 126 function getnameinfo 126 function gai_strerror 132 Obsolete Functions 132 Summary 133 Chapter 5: Communications 135 The Mechanics of Data Exchange 136 Socket Creation 137 function socket 141 function WSASocket 143 Making the Connection 144 function connect 147 function WSAConnect 149 function getpeername 154 function getsockname 155 Sending Data 160 function send 161 function WSASend 162 function sendto 163 function WSASendTo 164 Receiving Data 165 function recv 165 function WSARecv 166 function recvfrom 168 vii Contents function WSARecvfrom 169 Breaking the Connection 170 function shutdown 172 function closesocket 172 function WSASendDisconnect 173 function WSARecvDisconnect 174 Server Applications 174 Preparation 174 Duplicated Sockets 178 function bind 179 function listen 179 function accept 180 function WSAAccept 181 function WSADuplicateSocket 182 I/O Schemes 183 Using Select 183 Using WSAAsyncSelect 185 Using WSAEventSelect 188 Using Overlapped Routines 191 Event Notification 192 Completion I/O Schemes 193 Completion Port I/O Scheme 194 Which I/O Scheme to Use? 195 To Block or Not to Block? 196 Winsock and Multithreading 198 function select 203 function WSAAsyncSelect 203 function WSACreateEvent 210 function WSAWaitForMultipleEvents 215 function WSAEnumNetworkEvents 220 function WSAEventSelect 221 function WSACloseEvent 222 function WSAResetEvent 222 function WSASetEvent 223 function WSAGetOverlappedResult 224 Raw Sockets 225 Microsoft Extensions to Winsock 2 239 function AcceptEx 241 procedure GetAcceptExSockaddrs 242 function TransmitFile 243 function WSARecvEx 245 Microsoft Extensions to Winsock 2 for Windows XP and Windows .NET Server 246 function ConnectEx 247 function DisconnectEx 248 viii Contents function TransmitPackets 249 function WSANSPIoctl 251 function WSARecvMsg 252 IP Multicast 253 What is IP Multicast? 253 What Can You Do with IP Multicast? 255 How Do You Develop a Simple IP Multicast Application? 256 function WSAJoinLeaf 258 Obsolete Functions 261 function WSACancelBlockingCall 261 function WSAIsBlocking 262 function WSASetBlockingHook 263 function WSAUnhookBlockingHook 264 Summary 264 Chapter 6: Socket Options 265 Querying and Modifying Attributes 265 Option Level = SOL_SOCKET 270 Option = SO_DEBUG 270 Option = SO_KEEPALIVE 270 Option = SO_LINGER 271 Option = SO_REUSEADDR 271 Option = SO_RCVBUF and SO_SNDBUF 272 Option Level = IPPROTO_TCP 272 Option = TCP_NODELAY 272 Option Level = IPPROTO_IP 272 Option = IP_OPTIONS 272 Option = IP_HDRINCL 273 Option = IP_TOS 273 Option = IP_TTL 273 Option = IP_MULTICAST_IF 274 Option = IP_MULTICAST_TTL 274 Option = IP_MULTICAST_LOOP 274 Option = IP_ADD_MEMBERSHIP 274 Option = IP_DROP_MEMBERSHIP 274 Option = IP_DONTFRAGMENT 274 Modifying I/O Behavior 274 function getsockopt 278 function setsockopt 279 function ioctlsocket 279 function WSAIoctl 280 Summary 281 ix Contents [...]... smaller of the two, for experimental research These networks became known as the Internet of Internet is just a collection of smaller 2 NOTE: The meaningformthelarge network Therefore, we can use the networks to a generic term internet to refer to a network of smaller networks that is not the Internet The Internet expanded further when DARPA invited more universities to use the Internet for research and communications. .. NOTE: These APIswith in thebook This file should be oncompanion CD that comes this a path visible to Delphi By convention, you should put the Winsock2.pas file in the directory \Delphi 5\Lib Chapter 1 In this chapter, we covered the origins of the Internet, which led to the establishment of TCP/IP as the protocol suite of choice We reviewed the evolution of Winsock from BSD Sockets and briefly covered the. .. again through the layers on the peer’s side The following diagram makes this clear Figure 1-3 Before Winsock In the early years of the Internet, computers that used the Internet were of the mainframe and minicomputer pedigree Attached to these computers were dumb terminals that were used for e-mail, file transfer, and network news It was natural, therefore, that when PCs appeared on the scene, there was... and its new features To simplify coverage of the Winsock 2 API in the following chapters, the functions are grouped by the following topics: Chapter 2 Winsock Fundamentals In the last chapter, we provided a brief overview of the origins of the Internet and examined the evolution of BSD Sockets and the technology that gave birth to the Internet and provided the basis for Window’s Internet technology,... Diana, for their loving support during the development of this tome John C Penman xv Introduction Reliable communications using computers has been important for a long time, starting with DOS bulletin boards and the early days of the Internet In this book, we will provide an introduction to two of the essential communications technologies, Windows Sockets (Winsock), the backbone of the Internet on the Windows... implement Winsock is an API that is an integral part of Microsoft’s Windows Open Systems Architecture (WOSA), which we’ll discuss later in this chapter, as well as in the second half of the book dealing with TAPI Let’s start with the history of the genesis of the Internet to the present In the Beginning Nowadays, it’s easy to forget that the genesis of the Internet arose as a need for a dependable and robust... network applications The Sockets layer became a catalyst for the creation of network applications, which further fueled the expansion of the Internet With the expansion of the Internet, TCP/IP became the network protocol of choice The following properties of TCP/IP explain the rapid acceptance of TCP/IP: n It is vendor independent, meaning an open standard n It is a standard implementation on every... 5 The Internet’s rapid growth (and its continued growth) owes much to the development of the Hypertext Transfer Protocol (HTTP) that has provided the underpinnings for the World Wide Web Rightly or wrongly, the ordinary man and woman on the street now sees the World Wide Web as the Internet Internet protocols like HTTP, FTP, SMTP, and POP3 are high-level protocols that operate seamlessly on top of the. .. technology and a description of the Winsock-related chapters that follow Part II, written by Alan C Moore, is a complete introduction to basic TAPI programming Chapter 7 provides an introduction to this technology and a description of the TAPI-related chapters that follow As in other volumes in Wordware Publishing’s Tomes of Delphi series, most chapters include introductory sections on the various technologies,... addition to the familiar DNS for TCP/IP Scatter and Gather The support for “scatter and gather” is similar to the vectored I/O as supported by BSD Sockets Overlapped I/O Winsock 2 uses the overlapped I/O model from the Win32 API We will explain these functions in Chapter 5, Communications. ” Quality of Service With the increasing use of multimedia applications that require a varying and often large . Team-Fly ® The Tomes of Delphi: Basic 32-Bit Communications Programming Alan C. Moore and John C. Penman Wordware Publishing, Inc. Library of Congress Cataloging-in-Publication Data Moore,. C., 1943 The Tomes of Delphi : basic 32-bit communications programming / by Alan C. Moore and John C. Penman. p. cm. Includes bibliographical references and index. ISBN 1-5 562 2-7 5 2-3 (paperback) 1 involved with TAPI in the first place. The organization is Project JEDI, which produced the translation of the TAPI header file for use in Delphi. The pioneering work of the original translators,

Ngày đăng: 16/04/2014, 11:14

Mục lục

  • The Tomes of Delphi: Basic 32-Bit Communications Programming

  • Part I Internet/Intranet Programming with Winsock

    • Chapter 1 The Winsock API

      • Introduction

      • The OSI Network Model 1

      • New Features of Winsock

      • Chapter 2 Winsock Fundamentals

        • Starting and Closing Winsock

        • The Many Faces of the Winsock DLL

        • Resolution

          • Resolving Using a hosts File

          • Resolving Using a Local Database File with DNS

          • Blocking and Asynchronous Resolution

            • Host Resolution

            • Canceling an Outstanding Asynchronous Call

            • Chapter 4 Winsock 2 Resolution

              • Translation Functions

              • Address and String Conversion Functions

              • Name Space Resolution and Registration

                • Enumerating Name Spaces

                • Functions for the Future

                  • Making Your Winsock Applications Agnostic

                  • Chapter 5 Communications

                    • The Mechanics of Data Exchange

                    • I/ O Schemes

                      • Using Select()

                      • Microsoft Extensions to Winsock 2

                      • Microsoft Extensions to Winsock 2 for Windows XP

                      • IP Multicast

                        • What is IP Multicast?

                        • What Can You Do with IP Multicast?

Tài liệu cùng người dùng

Tài liệu liên quan