Windows Socket Message-Driven/WSAAsyncSelect Model. Prof. Lin Weiguo Copyleft 2009~2015, College of Computing, CUC
|
|
- Duane McKinney
- 6 years ago
- Views:
Transcription
1 Windows Socket Message-Driven/WSAAsyncSelect Model Prof. Lin Weiguo Copyleft 2009~2015, College of Computing, CUC Dec 2015
2 Note You should not assume that an example in this presentation is complete. Items may have been selected for illustration. It is best to get your code examples directly from the textbook and modify them to work. Use the lectures to understand the general principles. 2 Advanced Windows Network Programming
3 Windows Message Processing Windows Messages Windows-based applications are event-driven. They do not make explicit function calls to obtain input. Instead, they wait for the system to pass input to them. The system passes input to a window procedure in the form of messages. Messages are generated by both the system and applications. How a Single-Threaded Program Processes Messages MSG message; while (::GetMessage(&message, NULL, 0, 0)) { ::TranslateMessage(&message); ::DispatchMessage(&message); 3 Advanced Windows Network Programming
4 Message-driven Execution (Asynchronous): 4 Advanced Windows Network Programming
5 Message-Driven I/O Windows specific variant of non-blocking I/O The I/O functions continue to run in the background and the program is notified if: I/O operations are completed I/O operations can be executed An I/O error occurred Notification is done using window messages. Each Windows application (must have a GUI) has a message loop that processes window messages and other messages When we use Message-Driven I/O, we define a custom message that is sent to the message loop to notify us about the status of IO operations. 5 Advanced Windows Network Programming
6 Message Flow 6 Advanced Windows Network Programming
7 Win32 API Message Processing Every Window element has an associated Window Procedure - registered when the Window is created, for processing messages. LRESULT WndProc(HWND hwnd, UINT imessage, WPARAM wparam, LPARAM lparam ) { switch (imessage) { case WM_CREATE: DoCreate(); break; case WM_PAINT: Paint(); break; case WM_DESTROY: PostQuitMessage( 0 ); break; default: return DefWindowProc( hwnd, imessage, wparam, lparam ); return 0; 7 Advanced Windows Network Programming
8 MFC: Message Mapping Macro // Example for BEGIN_MESSAGE_MAP BEGIN_MESSAGE_MAP( CMyWindow, CFrameWnd ) ON_WM_PAINT() ON_COMMAND( IDM_ABOUT, OnAbout ) END_MESSAGE_MAP( ) BEGIN_MESSAGE_MAP(CComputeDlg, CDialog) ON_BN_CLICKED(IDC_START, &CComputeDlg::OnBnClickedStart) ON_BN_CLICKED(IDC_CANCEL, &CComputeDlg::OnBnClickedCancel) ON_WM_TIMER() END_MESSAGE_MAP() 8 Advanced Windows Network Programming
9 Create Message-driven Socket Winsock provides a useful asynchronous I/O model that allows an application to receive Windows message based notification of network events on a socket. This is accomplished by calling the WSAAsyncSelect function after creating a socket. Create Message-driven Socket Step 1: Create a socket as usual. Step 2: Use the WSAAsyncSelect function to turn the socket into a message-driven socket. Note: The WSAAsyncSelect and WSAEventSelect models provide asynchronous notification of the capability to read or write data. It does not provide asynchronous data transfer like the overlapped and completion port models. 9 Advanced Windows Network Programming
10 WSAAsyncSelect The WSAAsyncSelect function requests Windows message-based notification of network events for a socket. int WSAAsyncSelect( in SOCKET s, in HWND hwnd, in unsigned int wmsg, in long levent ); Parameters s [in]: A descriptor that identifies the socket for which event notification is required. hwnd [in] A handle that identifies the window that will receive a message when a network event occurs. wmsg [in] A message to be received when a network event occurs. levent [in] A bitmask that specifies a combination of network events in which the application is interested. Note: socket() creates a socket in blocking mode, WSAAsyncSelect() turns it to non-blocking mode. 10 Advanced Windows Network Programming
11 User-Defined Winsock Message Declare user message ID #define WM_WINSOCK (WM_USER + 100) Declare message handling function in the.h file afx_msg LRESULT OnWinsock(WPARAM wparam, LPARAM lparam); DECLARE_MESSAGE_MAP() Map the message to the handling function in.cpp file BEGIN_MESSAGE_MAP(CMYDlg, CDialog) ON_MESSAGE(WM_WINSOCK, OnWinsock) END_MESSAGE_MAP() Implement the message handling functon in.cpp file LRESULT CMyDlg::OnWinsock(WPARAM wparam, LPARAM lparam) {... return 0; 11 Advanced Windows Network Programming
12 Winsock Message Posting 12 Advanced Windows Network Programming
13 Posting winsock message int CMyDlg::StartMsgDrivenReceive() { //... int err = WSAAsyncSelect ( socket, m_hwnd, WM_WINSOCK, FD_READ FD_ACCEPT FD_CLOSE); if (err!= 0) { afxmessagebox("wsaasyncselect() failed! ); //... //... // Window handle, from MFC s CWindow 13 Advanced Windows Network Programming
14 Network Event Types for the WSAAsyncSelect Function Event Type FD_READ FD_WRITE FD_OOB FD_ACCEPT FD_CONNECT FD_CLOSE FD_QOS Meaning The application wants to receive notification of readiness for reading. The application wants to receive notification of readiness for writing. The application wants to receive notification of the arrival of OOB data. The application wants to receive notification of incoming connections. The application wants to receive notification of a completed connection or a multipoint join operation. The application wants to receive notification of socket closure. The application wants to receive notification of socket QOS changes. FD_GROUP_QOS FD_ROUTING_INTE RFACE_CHANGE FD_ADDRESS_LIST_ CHANGE The application wants to receive notification of socket group QOS changes (reserved for future use with socket groups). The application wants to receive notification of routing interface changes for the specified destination(s). The application wants to receive notification of local address list changes for the socket's protocol family. 14 Advanced Windows Network Programming
15 Setting the Event parameter WSAAsyncSelect(Sockfd, m_hwnd, WM_SOCKET, FD_READ FD_WRITE); // Activate both read & write. WSAAsyncSelect(Sockfd, hmywindow, WM_SOCKET, 0 // Disable all events. ); //a typical client WSAAsyncSelect(s, m_hwnd, WM_SOCKET, FD_CONNECT FD_READ FD_WRITE FD_CLOSE ); 15 Advanced Windows Network Programming
16 Server side WSAAsyncSelect SOCKET Listen = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP); // Bind the socket to port 5150 and begin listening for connections InternetAddr.sin_family = AF_INET; InternetAddr.sin_addr.s_addr = htonl(inaddr_any); InternetAddr.sin_port = htons(5150); bind(listen, (PSOCKADDR) &InternetAddr, sizeof(internetaddr)); // Set up window message notification on // the new socket using the WM_SOCKET define above WSAAsyncSelect(Listen, Window, WM_SOCKET, FD_ACCEPT FD_CLOSE); listen(listen, 5); // Translate and dispatch window messages // until the application terminates while (1) { // Advanced Windows Network Programming
17 Processing Winsock Message LRESULT CMyDlg::OnWinsock(WPARAM wparam, LPARAM lparam) { SOCKET sock = (SOCKET) wparam; int event = WSAGETSELECTEVENT(lParam); int WsaErr = WSAGETSELECTERROR(lParam); // Determine whether an error occurred on the socket by using the WSAGETSELECTERROR() macro if (WsaErr) { closesocket( sock ); return 0; switch(event)// Determine what event occurred on the socket { case FD_ACCEPT: OnAccept( sock ); break; // Accept an incoming connection case FD_READ: OnRead( sock ); break; // Receive data from the socket in wparam case FD_WRITE: OnWrite( sock ); break; // The socket in wparam is ready for sending data case FD_CLOSE: closesocket( sock); break; // The connection is now closed return 0; 17 Advanced Windows Network Programming
18 Processing Winsock Event:OnAccept() Void CMyDlg::OnAccept(SOCKET mysocket) { SOCKET AcceptedSock = accept(mysocket, NULL, NULL); if (total_conn >= MAX_CLIENT_NUM) //close if more than MAX client number { closesocket(acceptedsock); return; ClientSock[CurConn].Sock=AcceptedSock; //save the new socket to the connected list // Prepare accepted socket for read, write, and close notification WSAAsyncSelect(AcceptedSock, m_hwnd, WM_SOCKET, FD_READ FD_WRITE FD_CLOSE); Void CMyDlg::OnRead(SOCKET mysocket) { if (mysocket==serversock_udp) //UDP Echo { recvfrom( ); sendto( ); else if (mysocket!=serversock) //TCP Time server { recv( ); send( ); 18 Advanced Windows Network Programming
19 Alternative way for processing User-Defined Message Step 1: Select the dialog class in the Class view. Step 2: Go to Properties view. Click the icon for overrides (a green cube in VS.NET 2008). Find Window Proc in the list. Open the drop-list and select <Add> Window Proc. 19 Advanced Windows Network Programming
20 Alternative way for processing User-Defined Message Step 3: Add code to filter the defined custom message for network events // Override MFC's Window procedure to process the Winsock messages. LRESULT CMyDlg::WindowProc(UINT message, WPARAM wparam, LPARAM lparam) { // TODO: Add your specialized code here and/or call the base class if (message == WM_WINSOCK) { int event = WSAGETSELECTEVENT(lParam); int wsaerr = WSAGETSELECTERROR(lParam); switch (event) { case FD_READ : OnRead(); return 0; case FD_ACCEPT : OnAccept(); return 0; case FD_CLOSE : OnClose(); return 0; return CDialog::WindowProc(message, wparam, lparam); 20 Advanced Windows Network Programming
21 Winsock Event Triggering Edge-Triggered v.s. Level Triggered Re-enabling functions 21 Advanced Windows Network Programming
22 Winsock Event Triggering Level Trigger example: FD_READ 22 Advanced Windows Network Programming
23 Winsock Event Triggering Edge Trigger example: FD_WRITE 23 Advanced Windows Network Programming
24 On Write case FD_WRITE: // write event { while(true) { // read from a file into packet.data. in.read((char*)&packet.data, MAX_PACKET_SIZE); // sending data if (send(wparam, (char*)(&packet), sizeof(packet), 0) == SOCKET_ERROR) { if (WSAGetLastError() == WSAEWOULDBLOCK) { break; // socket internal buffer full else // other errors { // output error message, and return. CleanUp(); return(0); break; 24 Advanced Windows Network Programming
25 summary of events and conditions for asynchronous notification message. FD_READ: 1. When WSAAsyncSelect is called, if there is data currently available to receive. 2. When data arrives, if FD_READ is not already posted. 3. After recv or recvfrom is called, with or without MSG_PEEK, if data is still available to receive. FD_WRITE: 1. When WSAAsyncSelect called, if a send or sendto is possible. 2. After connect or accept called, when connection established. 3. After send or sendto fail with WSAEWOULDBLOCK, when send or sendto are likely to succeed. 4. After bind on a connectionless socket. FD_WRITE may or may not occur at this time (implementation-dependent). In any case, a connectionless socket is always writeable immediately after a bind operation. 25 Advanced Windows Network Programming
26 summary of events and conditions for asynchronous notification message. FD_ACCEPT: 1. When WSAAsyncSelect called, if there is currently a connection request available to accept. 2. When a connection request arrives, if FD_ACCEPT not already posted. 3. After accept called, if there is another connection request available to accept. FD_CONNECT: 1. When WSAAsyncSelect called, if there is currently a connection established. 2. After connect called, when connection is established, even when connect succeeds immediately, as is typical with a datagram socket. 3. After calling WSAJoinLeaf, when join operation completes. 4. After connect, WSAConnect, or WSAJoinLeaf was called with a nonblocking, connection-oriented socket. The initial operation returned with a specific error of WSAEWOULDBLOCK, but the network operation went ahead. Whether the operation eventually succeeds or not, when the outcome has been determined, FD_CONNECT happens. The client should check the error code to determine whether the outcome was successful or failed. 26 Advanced Windows Network Programming
27 summary of events and conditions for asynchronous notification message. FD_CLOSE: Only valid on connection-oriented sockets (for example, SOCK_STREAM) 1. When WSAAsyncSelect called, if socket connection has been closed. 2. After remote system initiated graceful close, when no data currently available to receive (Be aware that, if data has been received and is waiting to be read when the remote system initiates a graceful close, the FD_CLOSE is not delivered until all pending data has been read). 3. After local system initiates graceful close with shutdown and remote system has responded with "End of Data" notification (for example, TCP FIN), when no data currently available to receive. 4. When remote system terminates connection (for example, sent TCP RST), and lparam will contain WSAECONNRESET error value. Note FD_CLOSE is not posted after closesocket is called. 27 Advanced Windows Network Programming
28 Message-Driven Concurrent Server 28 Advanced Windows Network Programming
29 Summary The WSAAsyncSelect model offers many advantages foremost is the capability to handle many connections simultaneously without much overhead, unlike the select model's requirement of setting up the fd_set structures. The disadvantages are having to use a window if your application requires no windows (such as a service or console application). Also, having a single window procedure to service all the events on thousands of socket handles can become a performance bottleneck (meaning this model doesn't scale very well). 29 Advanced Windows Network Programming
30 references Programming With Microsoft Visual C++ NET 6 th Ed. - George/Kruglinski Shepherd Network Programming for Microsoft Windows, 2nd Ed. - Anthony Jones, Jim Ohlund MSDN: WSAAsyncSelect, WSAEventSelect Function CUHK Ieg4180: Network Software Design and Programming Drew Sikora, Programming with Asynchronous Sockets, GameDev.net, 2/1/ The C10K problem, 30 Advanced Windows Network Programming
Socket I/Os in Windows. Dae-Ki Kang
Socket I/Os in Windows Dae-Ki Kang Agenda TCP Server/Client Multi-Threads Synchronization Socket IO Model WSAAsyncSelect Model WSAEventSelect Model UDP Server/Client Overlapped Model Completion Port Model
More informationWindows Socket I/O Multiplexing. Prof. Lin Weiguo Copyleft 2009~2017 School of Computing, CUC
Windows Socket I/O Multiplexing Prof. Lin Weiguo Copyleft 2009~2017 School of Computing, CUC Dec 2016 Note You should not assume that an example in this presentation is complete. Items may have been selected
More informationProgramming in graphical environment. Introduction
Programming in graphical environment Introduction The lecture Additional resources available at: http://www.mini.pw.edu.pl/~maczewsk/windows_2004 Recommended books: Programming Windows - Charles Petzold
More informationI/O Multiplexing. Dec 2009
Windows Socket I/O Multiplexing http://icourse.cuc.edu.cn/networkprogramming/ linwei@cuc.edu.cn Dec 2009 Note You should not assume that an example in this presentation is complete. Items may have been
More informationWindows Sockets: A Quick And Dirty Primer
Windows Sockets: A Quick And Dirty Primer Page 1 of 11 Windows Sockets: A Quick And Dirty Primer by Jim Frost Last modified December 31, 1999 Contents Introduction What is a socket, anyway? (or: The Analogy)
More informationChapter 8: I/O functions & socket options
Chapter 8: I/O functions & socket options 8.1 Introduction I/O Models In general, there are normally two phases for an input operation: 1) Waiting for the data to arrive on the network. When the packet
More informationCMPT 212 Introduction to MFC and Windows Programming. Spring 2007
CMPT 212 Introduction to MFC and Windows Programming Spring 2007 What is MFC? MFC: Microsoft Foundation Classes MFC is a framework built on top of standard windows C++ libraries Provides the user with
More informationSimple network applications using sockets (BSD and WinSock) Revision 1 Copyright Clifford Slocombe
Simple network applications using sockets (BSD and WinSock) Revision 1 Copyright 2002 - Clifford Slocombe sockets@slocombe.clara.net COPYRIGHT 2002 - CLIFFORD SLOCOMBE PAGE 1 OF 8 Table of Contents Introduction...3
More informationEECS122 Communications Networks Socket Programming. Jörn Altmann
EECS122 Communications Networks Socket Programming Jörn Altmann Questions that will be Addressed During the Lecture What mechanisms are available for a programmer who writes network applications? How to
More informationWinSock. What Is Sockets What Is Windows Sockets What Are Its Benefits Architecture of Windows Sockets Network Application Mechanics
WinSock What Is Sockets What Is Windows Sockets What Are Its Benefits Architecture of Windows Sockets Network Application Mechanics What Is Sockets Standard API (Application Programming Interface) for
More informationClient Server Computing
Client Server Computing Although the Internet provides a basic communication service, the protocol software cannot initiate contact with, or accept contact from, a remote computer. Instead, two application
More informationUNIX Sockets. Developed for the Azera Group By: Joseph D. Fournier B.Sc.E.E., M.Sc.E.E.
UNIX Sockets Developed for the Azera Group By: Joseph D. Fournier B.Sc.E.E., M.Sc.E.E. Socket and Process Communication application layer User Process Socket transport layer (TCP/UDP) network layer (IP)
More informationIntroduction to Computer Networks
Introduction to Computer Networks Tian Song ( 嵩天 ), Ph.D., Assoc. Prof. songtian@bit.edu.cn Introduction to Computer Networks Socket and Network Programming Tian Song ( 嵩天 ), Ph.D., Assoc. Prof. songtian@bit.edu.cn
More informationUDP CONNECT TO A SERVER
UDP The User Datagram Protocol Stefan D. Bruda Winter 2018 Very similar to the TCP in terms of API Dissimilar with TCP in terms of innards (and hence programming techniques) Many-to-many communication.
More informationSocket Programming for TCP and UDP
CSCI4430 Data Communication and Computer Networks Socket Programming for TCP and UDP ZHANG, Mi Jan. 19, 2017 Outline Socket Programming for TCP Introduction What is TCP What is socket TCP socket programming
More informationPorts under 1024 are often considered special, and usually require special OS privileges to use.
1 2 Turns out that besides an IP address (used by the IP layer), there is another address that is used by TCP (stream sockets) and, coincidentally, by UDP (datagram sockets). It is the port number. It's
More informationThe User Datagram Protocol
The User Datagram Protocol Stefan D. Bruda Winter 2018 UDP Very similar to the TCP in terms of API Dissimilar with TCP in terms of innards (and hence programming techniques) Many-to-many communication.
More informationCS321: Computer Networks Socket Programming
CS321: Computer Networks Socket Programming Dr. Manas Khatua Assistant Professor Dept. of CSE IIT Jodhpur E-mail: manaskhatua@iitj.ac.in Socket Programming It shows how the network application programs
More informationChristian Tschudin (basierend auf einem Foliensatz von C. Jelger und T. Meyer) Departement Mathematik und Informatik, Universität Basel
Internettechnologien (CS262) Socket Programming in C 4. März 2015 Christian Tschudin (basierend auf einem Foliensatz von C. Jelger und T. Meyer) Departement Mathematik und Informatik, Universität Basel
More informationELEC / COMP 177 Fall Some slides from Kurose and Ross, Computer Networking, 5 th Edition
ELEC / COMP 177 Fall 2014 Some slides from Kurose and Ross, Computer Networking, 5 th Edition Project #1 Starts in one week Is your Linux environment all ready? Bring your laptop Work time after quick
More informationGroup-A Assignment No. 6
Group-A Assignment No. 6 R N Oral Total Dated Sign (2) (5) (3) (10) Title : File Transfer using TCP Socket Problem Definition: Use Python for Socket Programming to connect two or more PCs to share a text
More informationIdentifying Linchpin Vertices that Cause Large Dependence Clusters
Identifying Linchpin Vertices that Cause Large Dependence Clusters Dave Binkley Loyola University Maryland Mark Harman Crest Centre, Kings College London What s Coming Dependence Defined Dependence Clusters
More informationLecture 7. Followup. Review. Communication Interface. Socket Communication. Client-Server Model. Socket Programming January 28, 2005
Followup symbolic link (soft link): pathname, can be across file systems, replacement of file will be active on all symbolic links, consumes at least an inode. hard link: pointers to an inode, only in
More informationSocket Programming. Sungkyunkwan University. Hyunseung Choo Copyright Networking Laboratory
Socket Programming Sungkyunkwan University Hyunseung Choo choo@skku.edu Copyright 2000-2019 Networking Laboratory Contents Goals Client-Server mechanism Introduction to socket Programming with socket on
More informationOral. Total. Dated Sign (2) (5) (3) (2)
R N Oral Total Dated Sign (2) (5) (3) (2) Assignment Group- A_07 Problem Definition Write a program using TCP socket for wired network for following Say Hello to Each other ( For all students) File transfer
More informationSockets 15H2. Inshik Song
Sockets 15H2 Inshik Song Internet CAU www server (www.cau.ac.kr) Your web browser (Internet Explorer/Safari) Sockets 2 How do we find the server? Every computer on the Internet has an Internet address.
More informationInternet Connectivity with
Internet Connectivity with Introduction The purpose of this workshop is to help you g et acquainted with the basics of internet connectivity by leveraging ARM mbed tools. If you are not already familiar
More informationNETWORK PROGRAMMING. Instructor: Junaid Tariq, Lecturer, Department of Computer Science
NETWORK PROGRAMMING CSC- 341 25 Instructor: Junaid Tariq, Lecturer, Department of Computer Science 26 9 Lecture Sockets as means for inter-process communication (IPC) application layer Client Process Socket
More informationCS321: Computer Networks Introduction to Application Layer
CS321: Computer Networks Introduction to Application Layer Dr. Manas Khatua Assistant Professor Dept. of CSE IIT Jodhpur E-mail: manaskhatua@iitj.ac.in Basic Application layer provides services to the
More informationChapter 6. The Transport Layer. Transport Layer 3-1
Chapter 6 The Transport Layer Transport Layer 3-1 Transport services and protocols provide logical communication between app processes running on different hosts transport protocols run in end systems
More informationWindows and Messages. Creating the Window
Windows and Messages In the first two chapters, the sample programs used the MessageBox function to deliver text output to the user. The MessageBox function creates a "window." In Windows, the word "window"
More informationA Client-Server Exchange
Socket programming A Client-Server Exchange A server process and one or more client processes Server manages some resource. Server provides service by manipulating resource for clients. 1. Client sends
More information2007 Microsoft Corporation. All rights reserved.
Creating a Basic Winsock Application 2007 Microsoft Corporation. All rights reserved. To create a basic Winsock application 1. Create a new empty project. 2. Add an empty C++ source file to the project.
More informationChapter 15 Programming Paradigm
Chapter 15 Programming Paradigm A Windows program, like any other interactive program, is for the most part inputdriven. However, the input of a Windows program is conveniently predigested by the operating
More informationWinSock2 for Games by Stefan Hajnoczi 25 March 2000
WinSock2 for Games GameDev.net Introduction WinSock2 for Games by Stefan Hajnoczi http://www.intertainment.8m.com 25 March 2000 I went on #gamedev (my nick is jadam) the other day and asked if anybody
More informationNetwork Programming in Python. based on Chun, chapter 2; plus material on classes
Network Programming in Python based on Chun, chapter 2; plus material on classes What is Network Programming? Writing programs that communicate with other programs Communicating programs typically on different
More informationProgramming with TCP/IP. Ram Dantu
1 Programming with TCP/IP Ram Dantu 2 Client Server Computing Although the Internet provides a basic communication service, the protocol software cannot initiate contact with, or accept contact from, a
More informationRedesde Computadores(RCOMP)
Redesde Computadores(RCOMP) Theoretical-Practical (TP) Lesson 07 2016/2017 Berkeley sockets API, C and Java. Basic functions/methods for TCP applications. TCP client and server. Asynchronous reception.
More informationAdvantech Windows CE.net Application Hand on Lab
Advantech Windows CE.net Application Hand on Lab Lab : Serial Port Communication Objectives After completing this lab, you will be able to: Create an application to open, initialize the serial port, and
More informationUNIX Sockets. COS 461 Precept 1
UNIX Sockets COS 461 Precept 1 Socket and Process Communica;on application layer User Process Socket transport layer (TCP/UDP) OS network stack network layer (IP) link layer (e.g. ethernet) Internet Internet
More informationMotivation of VPN! Overview! VPN addressing and routing! Two basic techniques for VPN! ! How to guarantee privacy of network traffic?!
Overview!! Last Lecture!! Daemon processes and advanced I/O functions!! This Lecture!! VPN, NAT, DHCP!! Source: Chapters 19&22 of Comer s book!! Unix domain protocols and non-blocking I/O!! Source: Chapters
More informationInterprocess Communication Mechanisms
Interprocess Communication 1 Interprocess Communication Mechanisms shared storage These mechanisms have already been covered. examples: shared virtual memory shared files processes must agree on a name
More informationshared storage These mechanisms have already been covered. examples: shared virtual memory message based signals
Interprocess Communication 1 Interprocess Communication Mechanisms shared storage These mechanisms have already been covered. examples: shared virtual memory shared files processes must agree on a name
More informationSocket Programming. Dr. -Ing. Abdalkarim Awad. Informatik 7 Rechnernetze und Kommunikationssysteme
Socket Programming Dr. -Ing. Abdalkarim Awad Informatik 7 Rechnernetze und Kommunikationssysteme Before we start Can you find the ip address of an interface? Can you find the mac address of an interface?
More informationCSCE 463/612 Networks and Distributed Processing Spring 2017
CSCE 463/612 Networks and Distributed Processing Spring 2017 Preliminaries II Dmitri Loguinov Texas A&M University January 19, 2017 1 Agenda HTTP basics Windows sockets Clients 2 HTTP Basics General URL
More informationSocket Programming. CSIS0234A Computer and Communication Networks. Socket Programming in C
1 CSIS0234A Computer and Communication Networks Socket Programming in C References Beej's Guide to Network Programming Official homepage: http://beej.us/guide/bgnet/ Local mirror http://www.cs.hku.hk/~c0234a/bgnet/
More informationWindows Programming. 1 st Week, 2011
Windows Programming 1 st Week, 2011 시작하기 Visual Studio 2008 새프로젝트 파일 새로만들기 프로젝트 Visual C++ 프로젝트 Win32 프로젝트 빈프로젝트 응용프로그램설정 Prac01 솔루션 새항목추가 C++ 파일 main.cpp main0.cpp cpp 다운로드 솔루션빌드 오류 Unicode vs. Multi-Byte
More informationUNIT IV- SOCKETS Part A
1. Define sockets - SOCKETS Part A A socket is a construct to provide a communication between computers. It hides the underlying networking concepts and provides us with an interface to communicate between
More informationMemory-Mapped Files. generic interface: vaddr mmap(file descriptor,fileoffset,length) munmap(vaddr,length)
File Systems 38 Memory-Mapped Files generic interface: vaddr mmap(file descriptor,fileoffset,length) munmap(vaddr,length) mmap call returns the virtual address to which the file is mapped munmap call unmaps
More informationTypes (Protocols) Associated functions Styles We will look at using sockets in C Java sockets are conceptually quite similar
Socket Programming What is a socket? Using sockets Types (Protocols) Associated functions Styles We will look at using sockets in C Java sockets are conceptually quite similar - Advanced Data Communications:
More informationLecture 5 Overview! Last Lecture! This Lecture! Next Lecture! I/O multiplexing! Source: Chapter 6 of Stevens book!
Lecture 5 Overview! Last Lecture! I/O multiplexing! Source: Chapter 6 of Stevens book! This Lecture! Socket options! Source: Chapter 7 of Stevens book! Elementary UDP sockets! Source: Chapter 8 of Stevens
More informationOverview. Last Lecture. This Lecture. Daemon processes and advanced I/O functions
Overview Last Lecture Daemon processes and advanced I/O functions This Lecture Unix domain protocols and non-blocking I/O Source: Chapters 15&16&17 of Stevens book Unix domain sockets A way of performing
More informationRedes de Computadores (RCOMP)
Redes de Computadores (RCOMP) Theoretical-Practical (TP) Lesson 07 2017/2018 Berkeley sockets API, C and Java. Basic functions/methods for TCP applications. TCP client and server. Asynchronous reception.
More informationElementary TCP Sockets
Elementary TCP Sockets Chapter 4 UNIX Network Programming Vol. 1, Second Ed. Stevens Distributed Computer Systems 1 socket interface Application 1 Application 2 socket interface user kernel user kernel
More informationComputer Programming Lecture 11 이윤진서울대학교
Computer Programming Lecture 11 이윤진서울대학교 2007.1.24. 24 Slide Credits 엄현상교수님 서울대학교컴퓨터공학부 Computer Programming, g, 2007 봄학기 Object-Oriented Programming (2) 순서 Java Q&A Java 개요 Object-Oriented Oriented Programming
More informationCS 43: Computer Networks. 07: Concurrency and Non-blocking I/O Sep 17, 2018
CS 43: Computer Networks 07: Concurrency and Non-blocking I/O Sep 17, 2018 Reading Quiz Lecture 5 - Slide 2 Today Under-the-hood look at system calls Data buffering and blocking Inter-process communication
More informationCS 3516: Computer Networks
Welcome to CS 3516: Prof. Yanhua Li Time: 9:00am 9:50am M, T, R, and F Location: AK219 Fall 2018 A-term 1 Some slides are originally from the course materials of the textbook Computer Networking: A Top
More informationSTUDY OF SOCKET PROGRAMMING
STUDY OF SOCKET PROGRAMMING Sockets : An application programming interface(api) used for inter process communication. Sockets allow communication between two different processes on the same or different
More informationTransport Layer Review
Transport Layer Review Mahalingam Mississippi State University, MS October 1, 2014 Transport Layer Functions Distinguish between different application instances through port numbers Make it easy for applications
More informationLSN 4 GUI Programming Using The WIN32 API
LSN 4 GUI Programming Using The WIN32 API ECT362 Operating Systems Department of Engineering Technology LSN 4 Why program GUIs? This application will help introduce you to using the Win32 API Gain familiarity
More informationReview. Preview. Closing a TCP Connection. Closing a TCP Connection. Port Numbers 11/27/2017. Packet Exchange for TCP Connection
Review Preview Algorithms and Issues in Client Software Design Client Architecture Identifying the Location of a Parsing an Address Argument Looking Up a Domain Name Looking Up a Well-Known Port by Name
More informationHybrid of client-server and P2P. Pure P2P Architecture. App-layer Protocols. Communicating Processes. Transport Service Requirements
Announcements CS 5565 Network Architecture and Protocols Lecture 5 Godmar Back Problem Set 1 due Feb 17 Project 1 handed out shortly 2 Layer The Layer Let s look at some s (in keeping with top-down) architectures:
More informationProcesses communicating. Network Communication. Sockets. Addressing processes 4/15/2013
Processes communicating Network Communication Process: program running within a host. within same host, two processes communicate using inter-process communication (defined by OS). processes in different
More informationContext. Distributed Systems: Sockets Programming. Alberto Bosio, Associate Professor UM Microelectronic Departement
Distributed Systems: Sockets Programming Alberto Bosio, Associate Professor UM Microelectronic Departement bosio@lirmm.fr Context Computer Network hosts, routers, communication channels Hosts run applications
More informationCSE/EE 461 Lecture 14. Connections. Last Time. This Time. We began on the Transport layer. Focus How do we send information reliably?
CSE/EE 461 Lecture 14 Connections Last Time We began on the Transport layer Focus How do we send information reliably? Topics ARQ and sliding windows Application Presentation Session Transport Network
More informationInterprocess Communication
Interprocess Communication B.Ramamurthy CSE421 11/5/02 B.R 1 Topics Pipes (process level) Sockets (OS level) Distributed System Methods (Java s) Remote Method Invocation (PL Level) Other communication
More informationSOCKETS. COMP750 Distributed Systems
SOCKETS COMP750 Distributed Systems Sockets The Socket library is a traditional Application Program Interface (API) to the transport layer. Sockets were originally implemented in Unix systems and have
More informationNetwork Software Implementations
Network Software Implementations Number of computers on the Internet doubling yearly since 1981, nearing 200 million Estimated that more than 600 million people use the Internet Number of bits transmitted
More informationInterprocess Communication Mechanisms
Interprocess Communication 1 Interprocess Communication Mechanisms shared storage shared virtual memory shared files message-based sockets pipes signals Interprocess Communication 2 Message Passing Indirect
More informationInterprocess Communication Mechanisms
Interprocess Communication 1 Interprocess Communication Mechanisms shared storage shared virtual memory shared files message-based sockets pipes signals... Interprocess Communication 2 Message Passing
More informationOutline. Distributed Computer Systems. Socket Basics An end-point for a IP network connection. Ports. Sockets and the OS. Transport Layer.
Outline Distributed Computer Systems Socket basics Socket details (TCP and UDP) Socket options Final notes Sockets Socket Basics An end-point for a IP network connection what the application layer plugs
More informationEEC-484/584 Computer Networks
EEC-484/584 Computer Networks Lecture 15 wenbing@ieee.org (Lecture nodes are based on materials supplied by Dr. Louise Moser at UCSB and Prentice-Hall) Outline 2 Review of last lecture The network layer
More informationCSE 43: Computer Networks Structure, Threading, and Blocking. Kevin Webb Swarthmore College September 14, 2017
CSE 43: Computer Networks Structure, Threading, and Blocking Kevin Webb Swarthmore College September 14, 2017 1 Agenda Under-the-hood look at system calls Data buffering and blocking Processes, threads,
More informationOutline. Operating Systems. Socket Basics An end-point for a IP network connection. Ports. Network Communication. Sockets and the OS
Outline Operating Systems Socket basics Socket details Socket options Final notes Project 3 Sockets Socket Basics An end-point for a IP network connection what the application layer plugs into programmer
More informationI/O Models. Kartik Gopalan
I/O Models Kartik Gopalan Types of Concurrency True Concurrency (multiple processes or threads) Multi-processor machines Child processes/threads execute in parallel. Multi-process (forking) servers If
More informationServer algorithms and their design
Server algorithms and their design slide 1 many ways that a client/server can be designed each different algorithm has various benefits and problems are able to classify these algorithms by looking at
More informationLab 0. Yvan Petillot. Networks - Lab 0 1
Lab 0 Yvan Petillot Networks - Lab 0 1 What You Will Do In This Lab. The purpose of this lab is to help you become familiar with the UNIX/LINUX on the lab network. This means being able to do editing,
More informationsottotitolo Socket Programming Milano, XX mese 20XX A.A. 2016/17 Federico Reghenzani
Titolo presentazione Piattaforme Software per la Rete sottotitolo Socket Programming Milano, XX mese 20XX A.A. 2016/17 Outline 1) Introduction to Sockets 2) UDP communication 3) TCP communication 4) RAW
More informationOutline. Distributed Computing Systems. Socket Basics (1 of 2) Socket Basics (2 of 2) 3/28/2014
Outline Distributed Computing Systems Sockets Socket basics Socket details (TCP and UDP) Socket options Final notes Socket Basics (1 of 2) An end-point for an Internet network connection what application
More informationCOMP/ELEC 429/556 Introduction to Computer Networks
COMP/ELEC 429/556 Introduction to Computer Networks Creating a Network Application Some slides used with permissions from Edward W. Knightly, T. S. Eugene Ng, Ion Stoica, Hui Zhang 1 How to Programmatically
More informationWindow programming. Programming
Window programming 1 Objectives Understand the mechanism of window programming Understand the concept and usage of of callback functions Create a simple application 2 Overview Windows system Hello world!
More information(Refer Slide Time: 1:09)
Computer Networks Prof. S. Ghosh Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Lecturer # 30 UDP and Client Server Good day, today we will start our discussion
More informationCSCE 463/612 Networks and Distributed Processing Spring 2018
CSCE 463/612 Networks and Distributed Processing Spring 2018 Introduction Dmitri Loguinov Texas A&M University January 23, 2018 Original slides copyright 1996-2004 J.F Kurose and K.W. Ross 1 Updates Recv
More informationCS 640: Computer Networking
CS 640: Computer Networking Yu-Chi Lai Lecture 3 Network Programming Topics Client-server model Sockets interface Socket primitives Example code for echoclient and echoserver Debugging With GDB Programming
More informationLecture 7: Organizing Game Clients and Servers
Lecture 7: Organizing Game Clients and Servers! Socket: communication endpoints Analogous to a file descriptor Apps read/write data to/from sockets system handles delivery IP address: IP-level name of
More informationA Socket Example. Haris Andrianakis & Angelos Stavrou George Mason University
A Socket Example & George Mason University Everything is a file descriptor Most socket system calls operate on file descriptors Server - Quick view socket() bind() listen() accept() send(), recv() close()
More informationWinsock Server adding Multiple clients support C++
Winsock Server adding Multiple clients support C++ This is very simple version to add multiple connection support to your server project. Here we are going to use ioctlsocket to make it non blocking and
More informationBasics. Once socket is configured, applica6ons. Socket is an interface between applica6on and network
Socket Programming Basics Socket is an interface between applica6on and network Applica6on creates a socket Socket type dictates the style of communica6on Once socket is configured, applica6ons Pass data
More informationREAL TIME OPERATING SYSTEM PROGRAMMING-II: II: Windows CE, OSEK and Real time Linux. Lesson-9: WCE Serial Communication, Network, device-to
REAL TIME OPERATING SYSTEM PROGRAMMING-II: II: Windows CE, OSEK and Real time Linux Lesson-9: WCE Serial Communication, Network, device-to to-device socket and Communication Functions 1 1. Windows CE Serial
More informationIntroducing MFC. Programming Windows with MFC, Second Edition. Jeff Prosise
Introducing MFC Programming Windows with MFC, Second Edition. Jeff Prosise 1 Hello, MFC Short Years Ago Windows Applications written in C: Knowing the ins and outs of new operating system Knowing hundreds
More informationCptS 360 (System Programming) Unit 17: Network IPC (Sockets)
CptS 360 (System Programming) Unit 17: Network IPC (Sockets) Bob Lewis School of Engineering and Applied Sciences Washington State University Spring, 2018 Motivation Processes need to talk to each other
More informationChapter 2 Applications and
Chapter 2 Applications and Layered Architectures Sockets Socket API API (Application Programming Interface) Provides a standard set of functions that can be called by applications Berkeley UNIX Sockets
More informationSOCKET PROGRAMMING. What is a socket? Using sockets Types (Protocols) Associated functions Styles
LABORATORY SOCKET PROGRAMMING What is a socket? Using sockets Types (Protocols) Associated functions Styles 2 WHAT IS A SOCKET? An interface between application and network The application creates a socket
More information9th Slide Set Computer Networks
Prof. Dr. Christian Baun 9th Slide Set Computer Networks Frankfurt University of Applied Sciences WS1718 1/49 9th Slide Set Computer Networks Prof. Dr. Christian Baun Frankfurt University of Applied Sciences
More informationSocket Security: Using SO_REUSEADDR and SO_EXCLUSIVEADDRUSE
Socket Security: Using SO_REUSEADDR and Developing secure applications is a priority for most developers today; however, socket security is often overlooked but is especially critical. Socket security
More informationUsing the CFindReplaceDialog class By Tibor Blazko
Page 1 of 7 All Topics, MFC / C++ >> Dialog and Windows >> Windows Common dialogs Using the CFindReplaceDialog class By Tibor Blazko How to use the CFindReplaceDialog dialog for text searching Beginner
More informationHyo-bong Son Computer Systems Laboratory Sungkyunkwan University
Sockets Hyo-bong Son (proshb@csl.skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Client-Server Model Most network application is based on the client-server model: A server
More informationICT 6544 Distributed Systems Lecture 5
ICT 6544 Distributed Systems Lecture 5 Hossen Asiful Mustafa Message Brokers Figure 4-21. The general organization of a message broker in a message-queuing system. IBM s WebSphere Message-Queuing System
More informationNetwork Programming. Introduction to Sockets. Dr. Thaier Hayajneh. Process Layer. Network Layer. Berkeley API
Network Programming Outline Definitions Dr. Thaier Hayajneh Computer Engineering Department Berkeley API Socket definition and types Introduction to Sockets 1 2 Process Process Process Layer TCP SCTP UDP
More informationZ/TPF TCP/IP SOCK Driver 12/14/10. z/tpf TCP/IP SOCKET Driver Users Guide. Copyright IBM Corp. 2010
z/tpf TCP/IP SOCKET Driver Users Guide Copyright IBM Corp. 2010 1. 1.0 Introduction Z/TPF TCP/IP SOCK Driver 12/14/10 The socket driver consists of multiple DLMs that issue TCP/IP API calls to send and
More information