Suche senden
Hochladen
WinSock Asynchronous Input/Output
•
2 gefällt mir
•
1,722 views
C
calophatpho
Folgen
Business
Technologie
Design
Melden
Teilen
Melden
Teilen
1 von 16
Jetzt herunterladen
Downloaden Sie, um offline zu lesen
Empfohlen
Using Queryable State for Fun and Profit
Using Queryable State for Fun and Profit
Flink Forward
Introduction to Spark Streaming
Introduction to Spark Streaming
datamantra
Practical learnings from running thousands of Flink jobs
Practical learnings from running thousands of Flink jobs
Flink Forward
Apache Flink Worst Practices
Apache Flink Worst Practices
Konstantin Knauf
Scaling Flink in Cloud
Scaling Flink in Cloud
Steven Wu
Autoscaling Flink with Reactive Mode
Autoscaling Flink with Reactive Mode
Flink Forward
Introduction to Apache Flink
Introduction to Apache Flink
datamantra
Performance Troubleshooting Using Apache Spark Metrics
Performance Troubleshooting Using Apache Spark Metrics
Databricks
Empfohlen
Using Queryable State for Fun and Profit
Using Queryable State for Fun and Profit
Flink Forward
Introduction to Spark Streaming
Introduction to Spark Streaming
datamantra
Practical learnings from running thousands of Flink jobs
Practical learnings from running thousands of Flink jobs
Flink Forward
Apache Flink Worst Practices
Apache Flink Worst Practices
Konstantin Knauf
Scaling Flink in Cloud
Scaling Flink in Cloud
Steven Wu
Autoscaling Flink with Reactive Mode
Autoscaling Flink with Reactive Mode
Flink Forward
Introduction to Apache Flink
Introduction to Apache Flink
datamantra
Performance Troubleshooting Using Apache Spark Metrics
Performance Troubleshooting Using Apache Spark Metrics
Databricks
Real-time Analytics with Upsert Using Apache Kafka and Apache Pinot | Yupeng ...
Real-time Analytics with Upsert Using Apache Kafka and Apache Pinot | Yupeng ...
HostedbyConfluent
Apache Arrow: In Theory, In Practice
Apache Arrow: In Theory, In Practice
Dremio Corporation
Apache Spark Architecture | Apache Spark Architecture Explained | Apache Spar...
Apache Spark Architecture | Apache Spark Architecture Explained | Apache Spar...
Simplilearn
Parquet Strata/Hadoop World, New York 2013
Parquet Strata/Hadoop World, New York 2013
Julien Le Dem
Hive tuning
Hive tuning
Michael Zhang
Dynamic Allocation in Spark
Dynamic Allocation in Spark
Databricks
Improving Data Locality for Spark Jobs on Kubernetes Using Alluxio
Improving Data Locality for Spark Jobs on Kubernetes Using Alluxio
Alluxio, Inc.
CDC Stream Processing with Apache Flink
CDC Stream Processing with Apache Flink
Timo Walther
Apache Flink in the Cloud-Native Era
Apache Flink in the Cloud-Native Era
Flink Forward
Data Ingest Self Service and Management using Nifi and Kafka
Data Ingest Self Service and Management using Nifi and Kafka
DataWorks Summit
Accelerating Apache Spark Shuffle for Data Analytics on the Cloud with Remote...
Accelerating Apache Spark Shuffle for Data Analytics on the Cloud with Remote...
Databricks
ksqlDB - Stream Processing simplified!
ksqlDB - Stream Processing simplified!
Guido Schmutz
Photon Technical Deep Dive: How to Think Vectorized
Photon Technical Deep Dive: How to Think Vectorized
Databricks
SparkSQL: A Compiler from Queries to RDDs
SparkSQL: A Compiler from Queries to RDDs
Databricks
Designing Apache Hudi for Incremental Processing With Vinoth Chandar and Etha...
Designing Apache Hudi for Incremental Processing With Vinoth Chandar and Etha...
HostedbyConfluent
Batch Processing at Scale with Flink & Iceberg
Batch Processing at Scale with Flink & Iceberg
Flink Forward
Serverless Kafka and Spark in a Multi-Cloud Lakehouse Architecture
Serverless Kafka and Spark in a Multi-Cloud Lakehouse Architecture
Kai Wähner
Building an Interactive Query Service in Kafka Streams With Bill Bejeck | Cur...
Building an Interactive Query Service in Kafka Streams With Bill Bejeck | Cur...
HostedbyConfluent
Apache Flink Training: System Overview
Apache Flink Training: System Overview
Flink Forward
Stephan Ewen - Experiences running Flink at Very Large Scale
Stephan Ewen - Experiences running Flink at Very Large Scale
Ververica
T2: What the Second Generation Holds
T2: What the Second Generation Holds
Vlado Handziski
Symbian OS
Symbian OS
Adit Pathak
Weitere ähnliche Inhalte
Was ist angesagt?
Real-time Analytics with Upsert Using Apache Kafka and Apache Pinot | Yupeng ...
Real-time Analytics with Upsert Using Apache Kafka and Apache Pinot | Yupeng ...
HostedbyConfluent
Apache Arrow: In Theory, In Practice
Apache Arrow: In Theory, In Practice
Dremio Corporation
Apache Spark Architecture | Apache Spark Architecture Explained | Apache Spar...
Apache Spark Architecture | Apache Spark Architecture Explained | Apache Spar...
Simplilearn
Parquet Strata/Hadoop World, New York 2013
Parquet Strata/Hadoop World, New York 2013
Julien Le Dem
Hive tuning
Hive tuning
Michael Zhang
Dynamic Allocation in Spark
Dynamic Allocation in Spark
Databricks
Improving Data Locality for Spark Jobs on Kubernetes Using Alluxio
Improving Data Locality for Spark Jobs on Kubernetes Using Alluxio
Alluxio, Inc.
CDC Stream Processing with Apache Flink
CDC Stream Processing with Apache Flink
Timo Walther
Apache Flink in the Cloud-Native Era
Apache Flink in the Cloud-Native Era
Flink Forward
Data Ingest Self Service and Management using Nifi and Kafka
Data Ingest Self Service and Management using Nifi and Kafka
DataWorks Summit
Accelerating Apache Spark Shuffle for Data Analytics on the Cloud with Remote...
Accelerating Apache Spark Shuffle for Data Analytics on the Cloud with Remote...
Databricks
ksqlDB - Stream Processing simplified!
ksqlDB - Stream Processing simplified!
Guido Schmutz
Photon Technical Deep Dive: How to Think Vectorized
Photon Technical Deep Dive: How to Think Vectorized
Databricks
SparkSQL: A Compiler from Queries to RDDs
SparkSQL: A Compiler from Queries to RDDs
Databricks
Designing Apache Hudi for Incremental Processing With Vinoth Chandar and Etha...
Designing Apache Hudi for Incremental Processing With Vinoth Chandar and Etha...
HostedbyConfluent
Batch Processing at Scale with Flink & Iceberg
Batch Processing at Scale with Flink & Iceberg
Flink Forward
Serverless Kafka and Spark in a Multi-Cloud Lakehouse Architecture
Serverless Kafka and Spark in a Multi-Cloud Lakehouse Architecture
Kai Wähner
Building an Interactive Query Service in Kafka Streams With Bill Bejeck | Cur...
Building an Interactive Query Service in Kafka Streams With Bill Bejeck | Cur...
HostedbyConfluent
Apache Flink Training: System Overview
Apache Flink Training: System Overview
Flink Forward
Stephan Ewen - Experiences running Flink at Very Large Scale
Stephan Ewen - Experiences running Flink at Very Large Scale
Ververica
Was ist angesagt?
(20)
Real-time Analytics with Upsert Using Apache Kafka and Apache Pinot | Yupeng ...
Real-time Analytics with Upsert Using Apache Kafka and Apache Pinot | Yupeng ...
Apache Arrow: In Theory, In Practice
Apache Arrow: In Theory, In Practice
Apache Spark Architecture | Apache Spark Architecture Explained | Apache Spar...
Apache Spark Architecture | Apache Spark Architecture Explained | Apache Spar...
Parquet Strata/Hadoop World, New York 2013
Parquet Strata/Hadoop World, New York 2013
Hive tuning
Hive tuning
Dynamic Allocation in Spark
Dynamic Allocation in Spark
Improving Data Locality for Spark Jobs on Kubernetes Using Alluxio
Improving Data Locality for Spark Jobs on Kubernetes Using Alluxio
CDC Stream Processing with Apache Flink
CDC Stream Processing with Apache Flink
Apache Flink in the Cloud-Native Era
Apache Flink in the Cloud-Native Era
Data Ingest Self Service and Management using Nifi and Kafka
Data Ingest Self Service and Management using Nifi and Kafka
Accelerating Apache Spark Shuffle for Data Analytics on the Cloud with Remote...
Accelerating Apache Spark Shuffle for Data Analytics on the Cloud with Remote...
ksqlDB - Stream Processing simplified!
ksqlDB - Stream Processing simplified!
Photon Technical Deep Dive: How to Think Vectorized
Photon Technical Deep Dive: How to Think Vectorized
SparkSQL: A Compiler from Queries to RDDs
SparkSQL: A Compiler from Queries to RDDs
Designing Apache Hudi for Incremental Processing With Vinoth Chandar and Etha...
Designing Apache Hudi for Incremental Processing With Vinoth Chandar and Etha...
Batch Processing at Scale with Flink & Iceberg
Batch Processing at Scale with Flink & Iceberg
Serverless Kafka and Spark in a Multi-Cloud Lakehouse Architecture
Serverless Kafka and Spark in a Multi-Cloud Lakehouse Architecture
Building an Interactive Query Service in Kafka Streams With Bill Bejeck | Cur...
Building an Interactive Query Service in Kafka Streams With Bill Bejeck | Cur...
Apache Flink Training: System Overview
Apache Flink Training: System Overview
Stephan Ewen - Experiences running Flink at Very Large Scale
Stephan Ewen - Experiences running Flink at Very Large Scale
Ähnlich wie WinSock Asynchronous Input/Output
T2: What the Second Generation Holds
T2: What the Second Generation Holds
Vlado Handziski
Symbian OS
Symbian OS
Adit Pathak
Mod Security
Mod Security
Abhishek Singh
Stuxnet dc9723
Stuxnet dc9723
Iftach Ian Amit
Video phone
Video phone
J.T.A.JONES
Zaccone Carmelo - IPv6 and security from a user’s point of view
Zaccone Carmelo - IPv6 and security from a user’s point of view
IPv6 Conference
#OSSPARIS19: Construire des applications IoT "secure-by-design" - Thomas Gaza...
#OSSPARIS19: Construire des applications IoT "secure-by-design" - Thomas Gaza...
Paris Open Source Summit
Introducing MQTT
Introducing MQTT
Andy Piper
Symbian OS - Communication And Messaging
Symbian OS - Communication And Messaging
Andreas Jakl
The Considerations for Internet of Things @ 2017
The Considerations for Internet of Things @ 2017
Jian-Hong Pan
DEF CON 27 - workshop ANTHONY ROSE - introduction to amsi bypasses and sandbo...
DEF CON 27 - workshop ANTHONY ROSE - introduction to amsi bypasses and sandbo...
Felipe Prado
ucOS
ucOS
Ramasubbu .P
Blast off!
Blast off!
UltraUploader
Windows Filtering Platform And Winsock Kernel
Windows Filtering Platform And Winsock Kernel
Hardway Hou
Socketプログラム Silverlight for Windows Phoneへの移植のポイント
Socketプログラム Silverlight for Windows Phoneへの移植のポイント
Shin Ise
(120715) #fitalk the era of cyber sabotage and warfare (case study - stuxnet)
(120715) #fitalk the era of cyber sabotage and warfare (case study - stuxnet)
INSIGHT FORENSIC
(120715) #fitalk the era of cyber sabotage and warfare (case study - stuxnet)
(120715) #fitalk the era of cyber sabotage and warfare (case study - stuxnet)
INSIGHT FORENSIC
Practical steps to mitigate DDoS attacks
Practical steps to mitigate DDoS attacks
Martin Holovský
CVE 2012-1889 Microsoft XML core services uninitialized memory vulnerability
CVE 2012-1889 Microsoft XML core services uninitialized memory vulnerability
High-Tech Bridge SA (HTBridge)
Configuring cisco site to site ip sec vpn with dynamic ip endpoint cisco routers
Configuring cisco site to site ip sec vpn with dynamic ip endpoint cisco routers
phosika sithisane
Ähnlich wie WinSock Asynchronous Input/Output
(20)
T2: What the Second Generation Holds
T2: What the Second Generation Holds
Symbian OS
Symbian OS
Mod Security
Mod Security
Stuxnet dc9723
Stuxnet dc9723
Video phone
Video phone
Zaccone Carmelo - IPv6 and security from a user’s point of view
Zaccone Carmelo - IPv6 and security from a user’s point of view
#OSSPARIS19: Construire des applications IoT "secure-by-design" - Thomas Gaza...
#OSSPARIS19: Construire des applications IoT "secure-by-design" - Thomas Gaza...
Introducing MQTT
Introducing MQTT
Symbian OS - Communication And Messaging
Symbian OS - Communication And Messaging
The Considerations for Internet of Things @ 2017
The Considerations for Internet of Things @ 2017
DEF CON 27 - workshop ANTHONY ROSE - introduction to amsi bypasses and sandbo...
DEF CON 27 - workshop ANTHONY ROSE - introduction to amsi bypasses and sandbo...
ucOS
ucOS
Blast off!
Blast off!
Windows Filtering Platform And Winsock Kernel
Windows Filtering Platform And Winsock Kernel
Socketプログラム Silverlight for Windows Phoneへの移植のポイント
Socketプログラム Silverlight for Windows Phoneへの移植のポイント
(120715) #fitalk the era of cyber sabotage and warfare (case study - stuxnet)
(120715) #fitalk the era of cyber sabotage and warfare (case study - stuxnet)
(120715) #fitalk the era of cyber sabotage and warfare (case study - stuxnet)
(120715) #fitalk the era of cyber sabotage and warfare (case study - stuxnet)
Practical steps to mitigate DDoS attacks
Practical steps to mitigate DDoS attacks
CVE 2012-1889 Microsoft XML core services uninitialized memory vulnerability
CVE 2012-1889 Microsoft XML core services uninitialized memory vulnerability
Configuring cisco site to site ip sec vpn with dynamic ip endpoint cisco routers
Configuring cisco site to site ip sec vpn with dynamic ip endpoint cisco routers
Kürzlich hochgeladen
2024 Numerator Consumer Study of Cannabis Usage
2024 Numerator Consumer Study of Cannabis Usage
Neil Kimberley
Lowrate Call Girls In Sector 18 Noida ❤️8860477959 Escorts 100% Genuine Servi...
Lowrate Call Girls In Sector 18 Noida ❤️8860477959 Escorts 100% Genuine Servi...
lizamodels9
FULL ENJOY Call girls in Paharganj Delhi | 8377087607
FULL ENJOY Call girls in Paharganj Delhi | 8377087607
dollysharma2066
Kenya’s Coconut Value Chain by Gatsby Africa
Kenya’s Coconut Value Chain by Gatsby Africa
ictsugar
Annual General Meeting Presentation Slides
Annual General Meeting Presentation Slides
KeppelCorporation
Digital Transformation in the PLM domain - distrib.pdf
Digital Transformation in the PLM domain - distrib.pdf
Jos Voskuil
Youth Involvement in an Innovative Coconut Value Chain by Mwalimu Menza
Youth Involvement in an Innovative Coconut Value Chain by Mwalimu Menza
ictsugar
BEST Call Girls In Old Faridabad ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,
BEST Call Girls In Old Faridabad ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,
noida100girls
Japan IT Week 2024 Brochure by 47Billion (English)
Japan IT Week 2024 Brochure by 47Billion (English)
Data Analytics Company - 47Billion Inc.
Corporate Profile 47Billion Information Technology
Corporate Profile 47Billion Information Technology
Data Analytics Company - 47Billion Inc.
Flow Your Strategy at Flight Levels Day 2024
Flow Your Strategy at Flight Levels Day 2024
Kirill Klimov
Pitch Deck Teardown: Geodesic.Life's $500k Pre-seed deck
Pitch Deck Teardown: Geodesic.Life's $500k Pre-seed deck
HajeJanKamps
Keppel Ltd. 1Q 2024 Business Update Presentation Slides
Keppel Ltd. 1Q 2024 Business Update Presentation Slides
KeppelCorporation
Intro to BCG's Carbon Emissions Benchmark_vF.pdf
Intro to BCG's Carbon Emissions Benchmark_vF.pdf
pollardmorgan
Global Scenario On Sustainable and Resilient Coconut Industry by Dr. Jelfina...
Global Scenario On Sustainable and Resilient Coconut Industry by Dr. Jelfina...
ictsugar
/:Call Girls In Indirapuram Ghaziabad ➥9990211544 Independent Best Escorts In...
/:Call Girls In Indirapuram Ghaziabad ➥9990211544 Independent Best Escorts In...
lizamodels9
Call Girls In Sikandarpur Gurgaon ❤️8860477959_Russian 100% Genuine Escorts I...
Call Girls In Sikandarpur Gurgaon ❤️8860477959_Russian 100% Genuine Escorts I...
lizamodels9
The CMO Survey - Highlights and Insights Report - Spring 2024
The CMO Survey - Highlights and Insights Report - Spring 2024
christinemoorman
8447779800, Low rate Call girls in Uttam Nagar Delhi NCR
8447779800, Low rate Call girls in Uttam Nagar Delhi NCR
ashishs7044
8447779800, Low rate Call girls in Shivaji Enclave Delhi NCR
8447779800, Low rate Call girls in Shivaji Enclave Delhi NCR
ashishs7044
Kürzlich hochgeladen
(20)
2024 Numerator Consumer Study of Cannabis Usage
2024 Numerator Consumer Study of Cannabis Usage
Lowrate Call Girls In Sector 18 Noida ❤️8860477959 Escorts 100% Genuine Servi...
Lowrate Call Girls In Sector 18 Noida ❤️8860477959 Escorts 100% Genuine Servi...
FULL ENJOY Call girls in Paharganj Delhi | 8377087607
FULL ENJOY Call girls in Paharganj Delhi | 8377087607
Kenya’s Coconut Value Chain by Gatsby Africa
Kenya’s Coconut Value Chain by Gatsby Africa
Annual General Meeting Presentation Slides
Annual General Meeting Presentation Slides
Digital Transformation in the PLM domain - distrib.pdf
Digital Transformation in the PLM domain - distrib.pdf
Youth Involvement in an Innovative Coconut Value Chain by Mwalimu Menza
Youth Involvement in an Innovative Coconut Value Chain by Mwalimu Menza
BEST Call Girls In Old Faridabad ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,
BEST Call Girls In Old Faridabad ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,
Japan IT Week 2024 Brochure by 47Billion (English)
Japan IT Week 2024 Brochure by 47Billion (English)
Corporate Profile 47Billion Information Technology
Corporate Profile 47Billion Information Technology
Flow Your Strategy at Flight Levels Day 2024
Flow Your Strategy at Flight Levels Day 2024
Pitch Deck Teardown: Geodesic.Life's $500k Pre-seed deck
Pitch Deck Teardown: Geodesic.Life's $500k Pre-seed deck
Keppel Ltd. 1Q 2024 Business Update Presentation Slides
Keppel Ltd. 1Q 2024 Business Update Presentation Slides
Intro to BCG's Carbon Emissions Benchmark_vF.pdf
Intro to BCG's Carbon Emissions Benchmark_vF.pdf
Global Scenario On Sustainable and Resilient Coconut Industry by Dr. Jelfina...
Global Scenario On Sustainable and Resilient Coconut Industry by Dr. Jelfina...
/:Call Girls In Indirapuram Ghaziabad ➥9990211544 Independent Best Escorts In...
/:Call Girls In Indirapuram Ghaziabad ➥9990211544 Independent Best Escorts In...
Call Girls In Sikandarpur Gurgaon ❤️8860477959_Russian 100% Genuine Escorts I...
Call Girls In Sikandarpur Gurgaon ❤️8860477959_Russian 100% Genuine Escorts I...
The CMO Survey - Highlights and Insights Report - Spring 2024
The CMO Survey - Highlights and Insights Report - Spring 2024
8447779800, Low rate Call girls in Uttam Nagar Delhi NCR
8447779800, Low rate Call girls in Uttam Nagar Delhi NCR
8447779800, Low rate Call girls in Shivaji Enclave Delhi NCR
8447779800, Low rate Call girls in Shivaji Enclave Delhi NCR
WinSock Asynchronous Input/Output
1.
WinSock Asynchronous
Input/Output ECE 4564: Network Application Design Scott F. Midkiff Bradley Department of Electrical and Computer Engineering Virginia Polytechnic Institute and State University Topics ! Need for specialized WinSock calls ! Blocking and message-driven architecture ! Asynchronous calls " Message-based " Event-based " Asynchronous TCP ECHO server example " Database calls ! WinSock version checking ECE 4564: Network Application Design (10/6/2002) WinSock Asynchronous I/O - 2 © 1998-2002, Scott F. Midkiff
2.
WinSock ≠ BSD
UNIX Sockets ! WinSock 1.1 and 2.2 “core” calls are based on BSD UNIX Sockets model " Builds on existing knowledge base -- BSD UNIX Sockets widely used by network programmers " Simplifies porting of applications from UNIX to Microsoft Windows ! Usual socket calls may not be the best to use in Windows, especially for windowed applications " Blocking can cause problems for message-driven operating system " May not take full advantage of Windows advanced I/O features ECE 4564: Network Application Design (10/6/2002) WinSock Asynchronous I/O - 3 Message-Driven Architecture (1) ! Microsoft Windows is message-driven " System indicates “events” by providing a message to a program " The program responds to the message " The response may lead to new messages being sent at a later time or new messages may occur because of user actions ! Messages indicate different system events " User interface action " I/O completion " System call completion " Error conditions ECE 4564: Network Application Design (10/6/2002) WinSock Asynchronous I/O - 4 © 1998-2002, Scott F. Midkiff
3.
Message-Driven Architecture (2)
! Windows programs must check messages and will be unresponsive if messages are not checked " Not an issue for console applications ! Multitasking scheme determines how processes share the processor -- and when messages are checked " 16-bit Windows (3.1 and 3.11) uses cooperative multitasking " 32-bit Windows (95, 98, ME, NT, 2000, and XP) uses preemptive multitasking ECE 4564: Network Application Design (10/6/2002) WinSock Asynchronous I/O - 5 Cooperative Multitasking ! Processes must check for messages to keep system “alive” Message ! Blocked calls block the Queue entire system Dispatch Process Process ... Process GetMessage() PeekMessage() ECE 4564: Network Application Design (10/6/2002) WinSock Asynchronous I/O - 6 © 1998-2002, Scott F. Midkiff
4.
Preemptive Multitasking (1)
... Message Queues Dispatch Dispatch Thread Thread GetMessage() GetMessage() PeekMessage() PeekMessage() ECE 4564: Network Application Design (10/6/2002) WinSock Asynchronous I/O - 7 Preemptive Multitasking (2) ! Each thread has a message queue ! Operating system preempts threads so that a single blocked thread will not block other threads ! Blocking can make an application unresponsive and should be avoided, at least in user interface threads ECE 4564: Network Application Design (10/6/2002) WinSock Asynchronous I/O - 8 © 1998-2002, Scott F. Midkiff
5.
Messages and Application
Code (1) ! A Windows application defines a procedure to handle messages for a window ! Example: dialog process or DialogProc() " hwndDlg identifies where to to send messages " uMsg, with wParam and lParam, define message BOOL CALLBACK DialogProc( HWND hwndDlg, // handle to dialog box UINT uMsg, // message WPARAM wParam, // 1st message parameter LPARAM lParam // 2nd message parameter ); ECE 4564: Network Application Design (10/6/2002) WinSock Asynchronous I/O - 9 Messages and Application Code (2) ! Dialog procedure processes messages switch(uMsg) { case WM_INITDIALOG: // process initialization message case WM_COMMAND: // process user interface message case SM_EVENT: // process asynchronous WinSock event … } ECE 4564: Network Application Design (10/6/2002) WinSock Asynchronous I/O - 10 © 1998-2002, Scott F. Midkiff
6.
Non-Blocking WinSock Calls
! To prevent blocking in an application thread, use non-blocking WinSock calls ! Two approaches " Non-blocking sockets # ioctlsocket() to make socket non-blocking # select() to determine readiness of socket # Largely portable to UNIX " Asynchronous calls (preferred method) # Asynchronous call returns immediately # Completion is indicated to application (three notification methods) # Windows-specific (WSA prefix for function names) ECE 4564: Network Application Design (10/6/2002) WinSock Asynchronous I/O - 11 Notification Methods (1) ! Three notification methods $ Message-driven % Event-driven & Callback routine ! Message-driven notification " Window handle passed to WSAAsyncSelect() or other asynchronous call " Message is sent to indicated window procedure upon completion " Requires a windowed application ECE 4564: Network Application Design (10/6/2002) WinSock Asynchronous I/O - 12 © 1998-2002, Scott F. Midkiff
7.
Notification Methods (2)
! Event-driven notification " Event handle passed to WSAEventSelect() or other asynchronous call " Event is signaled, application must check " Can be used with any application ! Callback routine " Pointer to callback procedure is passed to call such as WSASend() or WSARecv() " WinSock “calls back” at indicated procedure when action is completed " Can be used with any application ECE 4564: Network Application Design (10/6/2002) WinSock Asynchronous I/O - 13 WSAAsyncSelect() (1) ! Makes socket non-blocking " No need to call ioctlsocket() ! Allows application to tell WinSock that messages should be sent for certain events " When a connection is established " When data is ready for receiving from socket " When data can be sent to socket (following a situation when data cannot be sent) " When socket is closed by peer " When out-of-band data is received " When socket or socket group quality of service (QoS) changes ECE 4564: Network Application Design (10/6/2002) WinSock Asynchronous I/O - 14 © 1998-2002, Scott F. Midkiff
8.
WSAAsyncSelect() (2) !
Note that one message is created for any event — cannot have different messages " wParam is the socket descriptor " lParam contains event code and error code # WSAGETSELECTEVENT(lParam) # WSAGETSELECTERROR(lParam) int WSAAsyncSelect ( SOCKET s, // socket HWND hWnd, // window for messages unsigned int wMsg, // message number long lEvent // types of events ); ECE 4564: Network Application Design (10/6/2002) WinSock Asynchronous I/O - 15 WSAAsyncSelect() (3) ! Example call " Define SM_EVENT as the message to be sent to window with handle hWnd " Check for connect, close, read, and write events on socket sock #define SM_EVENT WM_USER + 1 cc = WSAAsyncSelect ( sock, hWnd, SM_EVENT, FD_CONNECT| FD_CLOSE | FD_READ | FD_WRITE ); ECE 4564: Network Application Design (10/6/2002) WinSock Asynchronous I/O - 16 © 1998-2002, Scott F. Midkiff
9.
WSAEventSelect() (1) !
Note that WSAAsyncSelect() requires that the application have a window to receive messages ! Windows are not always suitable " Console applications are simpler to design " Long-running servers ! WSAEventSelect() allows asynchronous notifications to be provided to applications, which may or may not have a window " Sets an event object instead of posting a message to a window handle ECE 4564: Network Application Design (10/6/2002) WinSock Asynchronous I/O - 17 WSAEventSelect() (2) ! Makes socket non-blocking ! Allows application to specify event types for which the event will be set " Same set as for WSAAsyncSelect() " Event bit mask int WSAEventSelect ( SOCKET s, // socket WSAEVENT hEventObject, // event handle long lNetworkEvents // event bit mask ); ECE 4564: Network Application Design (10/6/2002) WinSock Asynchronous I/O - 18 © 1998-2002, Scott F. Midkiff
10.
Asynchronous Echo: Overview
! TCP ECHO server with asynchronous event notification (aechod.cpp) ! Similar in concept to singly-threaded concurrent TCP ECHO server (tcpmechod.cpp) ! Two classes of sockets " Master socket (index = 0) # Monitor when ready for accept (FD_ACCEPT) " Sockets for connections to clients (index > 0) # Monitor when ready for read or write or when a close occurs (FD_READ | FD_WRITE | FD_CLOSE) ECE 4564: Network Application Design (10/6/2002) WinSock Asynchronous I/O - 19 Asynchronous Echo: Calls (1) ! WSACreateEvent() " Used to create an event object " One event object per socket " Events[NumSock] = WSACreateEvent(); ! WSAEventSelect() " Used to indicate monitored event types " Master socket: WSAEventSelect(temp_sock, Events[0], FD_ACCEPT); " Per connection socket: WSAEventSelect(temp_sock, Events[NumSock], FD_READ | FD_WRITE | FD_CLOSE); ECE 4564: Network Application Design (10/6/2002) WinSock Asynchronous I/O - 20 © 1998-2002, Scott F. Midkiff
11.
Asynchronous Echo: Calls
(2) ! WaitForMultipleEvents() " Used to wait for any one event to be signaled " SigEvent = WSAWaitForMultipleEvents( NumSocks, Events, FALSE, WSA_INFINITE, FALSE ); DWORD WSAWaitForMultipleEvents( DWORD cEvents, // number of events const WSAEVENT FAR *lphEvents, // array BOOL fWaitAll, // wait for all events DWORD dwTimeOUT, // time out value BOOL fAlertable // make alertable ); ECE 4564: Network Application Design (10/6/2002) WinSock Asynchronous I/O - 21 Asynchronous Echo: Calls (3) ! WSAEnumNetworkEvents() " Determine triggering event, e.g. FD_READ int WSAEnumNetworkEvents ( SOCKET s, WSAEVENT hEventObject, LPWSANETWORKEVENTS lpNetworkEvents ); typedef struct _WSANETWORKEVENTS { long lNetworkEvents; int iErrorCodes[FD_MAX_EVENTS]; } WSANETWORKEVENTS, FAR * LPWSANETWORKEVENTS; ECE 4564: Network Application Design (10/6/2002) WinSock Asynchronous I/O - 22 © 1998-2002, Scott F. Midkiff
12.
Asynchronous Echo: Calls
(4) ! WSACloseEvent() " Releases event object " WSACloseEvent(Events[EventNum]); ECE 4564: Network Application Design (10/6/2002) WinSock Asynchronous I/O - 23 Asynchronous Echo: Data Structures ! Array of event handles " WSAEVENT Events[MAXSOCKS]; ! Array of socket information structures struct info { SOCKET sock; int state; char buf[BUFSIZE]; char * bufptr; int buflen; }; struct info * Socks[MAXSOCKS]; ECE 4564: Network Application Design (10/6/2002) WinSock Asynchronous I/O - 24 © 1998-2002, Scott F. Midkiff
13.
Asynchronous Echo: Operation
FD_WRITE && block FD_WRITE && block FD_READ && !block awaiting FD_ACCEPT recv(), send() accept() FD_READ && block send() recv(), send() READING WRITING FD_WRITE && !block send() FD_CLOSE FD_CLOSE cleanup CLOSING closed send() FD_WRITE && !block send(), cleanup ECE 4564: Network Application Design (10/6/2002) WinSock Asynchronous I/O - 25 Asynchronous Database Functions ! Asynchronous version of getXbyY() calls " WSAGetHostByAddr() " WSAGetHostByName() " WSAGetProtoByNumber() " WSAGetProtoByName() " WSAGetServByPort() " WSAGetServByName() ! Most important are WSAGetHostByAddr() and WSAGetHostByName() because of long potential delays ! Special call to cancel outstanding request " WSACancelAsyncRequest() ECE 4564: Network Application Design (10/6/2002) WinSock Asynchronous I/O - 26 © 1998-2002, Scott F. Midkiff
14.
WSAAsyncGetHostByName() ! Identify
window and message as in WSAAsyncSelect() ! Provide host name and return buffer " Buffer must be large enough for all information since no information is stored by WinSock HANDLE WSAAsyncGetHostByName ( HWND hWnd, // window for msg unsigned int wMsg, // message id const char FAR * name, // host name char FAR * buf, // return info int buflen // buffer length ); ECE 4564: Network Application Design (10/6/2002) WinSock Asynchronous I/O - 27 WinSock Version Checking (1) ! WSAStartup() " Version requested is an input parameter " Returned LPWSADATA structure indicates # Version that WinSock expects application to use # Highest version supported by this WinSock ! For example, if version 1.1 is requested from WinSock 2.2 " Version requested is 1.1 " Version expected (wVersion) is 1.1 " Highest version supported (wHighVersion) is 2.2 ECE 4564: Network Application Design (10/6/2002) WinSock Asynchronous I/O - 28 © 1998-2002, Scott F. Midkiff
15.
WinSock Version Checking
(2) Results from WSAStartup() Version Version Running Requested wVersion wHighVersion 1.1 1.0 WSAVERNOTSUPPORTED* 1.1 1.1 1.1 1.1 1.1 2.0 1.1 1.1 2.0 1.1 1.1 2.0 2.0 2.2 2.0 2.0 2.2 2.0 2.0 2.2 2.2 2.2 2.2 2.2 * Error return from WSAStartup() ECE 4564: Network Application Design (10/6/2002) WinSock Asynchronous I/O - 29 WinSock Version Checking (3) ! A robust application should ensure that requested version is supported if(WSAStartup(wVersionReq, &wsaData)!= 0){ // Check for error return } else if (wsaData.wVersion != wVersionReq) { // Version not supported } else { // Version is supported } ECE 4564: Network Application Design (10/6/2002) WinSock Asynchronous I/O - 30 © 1998-2002, Scott F. Midkiff
16.
You should now
be able to … ! Indicate the benefit of non-blocking calls in a message-driven operating system such as Microsoft Windows ! Describe basic mechanisms for notification including messages and events ! Analyze and design simple programs using asynchronous sockets with event-based notification ! Describe the asynchronous database calls ! Analyze and design code that verifies WinSock versions ECE 4564: Network Application Design (10/6/2002) WinSock Asynchronous I/O - 31 © 1998-2002, Scott F. Midkiff
Jetzt herunterladen