Winsock Server adding Multiple clients support C++
|
|
- Christopher Tate
- 6 years ago
- Views:
Transcription
1 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 small struct table for saving the client sockets. You should have some sort of experience with winsockets or at least knowing how recv and send functions work. If you are interested for getting to know winsockets better then you should head to microsoft developer pages, cause pretty much everything else on the web is garbage and they seem to keep example codes updated on msdn pages. Also you should know that the non blocking version is very cpu hungry cause of continuous polling but with little tweak we can make it work nicely, especially with something small. Asynchronous Sockets are for something bigger and stable, they kinda take non blocking sockets to next level. Hope this helps you to find I/O strategy you are looking for. This is the top of our code and almost all variables are there. And don't forget to link ws2_32 library. #define WIN32_LEAN_AND_MEAN #include <windows.h> #include <iostream> #include <winsock2.h> // Need to link with Ws2_32.lib #pragma comment (lib, "Ws2_32.lib") // #pragma comment (lib, "Mswsock.lib") using namespace std; #define DEFAULT_PORT #define DEFAULT_BUFLEN 512 #define MAX_CLIENTS 50 char recvbuf[default_buflen] = ""; int len, receiveres, clients_connected = 0; bool active = TRUE; SOCKET server_socket = INVALID_SOCKET; SOCKET client_fd; sockaddr_in server; //table for clients sockets struct _clients_b { ; bool connected; SOCKET ss; _clients_b clients[max_clients]; //function declarations void start_server();
2 In this function we are setting up the server and i decided to put it all in one function, to make it more easier to read. So basically start_server function is made of: WSAStartup socket setsockopt bind listen ioctlsocket int main() { cout << "Server starting..." << endl; //start the server and do basic tcp setup start_server(); //the main loop while (active) { //start accepting clients len = sizeof(server); client_fd = accept(server_socket, (struct sockaddr*)& server, &len); //our client is a real thing? if (client_fd!= INVALID_SOCKET) { //save client socket into our struct table clients[clients_connected].ss = client_fd; clients[clients_connected].connected = TRUE; //and of course we need a calculator too clients_connected++; cout << "New client: " << client_fd << endl; ever //we might need to add some delays cause our code might be too fast //commenting this function will eat your cpu like the hungriest dog //plus we don't need to loop that fast anyways Sleep(1); //receiving and sending data //we have clients or no? if (clients_connected > 0) { //lets go through all our clients for (int cc = 0; cc < clients_connected; cc++) { memset(&recvbuf, 0, sizeof(recvbuf)); if (clients[cc].connected) {
3 DEFAULT_BUFLEN, 0); //receive data receiveres = recv(clients[cc].ss, recvbuf, //and echo it back if we get any if (receiveres > 0) { Sleep(10); << endl; 0); data "disconnect") == 0) { cout << "Client data received: " << recvbuf send(client_fd, recvbuf, strlen(recvbuf), //how to close connection //this just for quick example //so you are just getting rid off client's socket else if (receiveres == 0 strcmp(recvbuf, cout << "Client disconnected." << endl; clients[cc].connected = FALSE; clients_connected--; //delete [cc] clients; //when we shut down our server closesocket(server_socket); // Clean up winsock return 0; void start_server() { int wsaresult, i = 1; WSADATA wsadata; server.sin_family = AF_INET; server.sin_addr.s_addr = INADDR_ANY; server.sin_port = htons(default_port); // Initialize Winsock wsaresult = WSAStartup(MAKEWORD(2, 2), &wsadata); //if error if (wsaresult!= 0) { printf("wsastartup failed with error: %d\n", wsaresult); // Create a SOCKET for connecting to server server_socket = socket(af_inet, SOCK_STREAM, IPPROTO_TCP); if (server_socket == INVALID_SOCKET) {
4 printf("socket failed with error: %ld\n", WSAGetLastError()); setsockopt(server_socket, SOL_SOCKET, SO_REUSEADDR, (char *)&i, sizeof(i)); //Binding part wsaresult = bind(server_socket, (sockaddr*)&server, sizeof(server)); if (wsaresult == SOCKET_ERROR) { printf("bind failed with error: %d\n", WSAGetLastError()); closesocket(server_socket); // Setup the TCP listening socket wsaresult = listen(server_socket, 5); unsigned long b = 1; //make it non blocking ioctlsocket(server_socket, FIONBIO, &b); if (wsaresult == SOCKET_ERROR) { printf("listen failed with error: %d\n", WSAGetLastError()); closesocket(server_socket); Client Code #define WIN32_LEAN_AND_MEAN #include <windows.h> #include <winsock2.h> #include <ws2tcpip.h> #include <stdlib.h> #include <stdio.h> #include <iostream> #include <string> using namespace std; // Need to link with Ws2_32.lib, Mswsock.lib, and Advapi32.lib #pragma comment (lib, "Ws2_32.lib") #pragma comment (lib, "Mswsock.lib") #pragma comment (lib, "AdvApi32.lib") #define DEFAULT_BUFLEN 512 #define DEFAULT_PORT "27015"
5 int cdecl main(int argc, char **argv) { WSADATA wsadata; SOCKET ConnectSocket = INVALID_SOCKET; struct addrinfo *result = NULL, *ptr = NULL, hints; char sendbuf[default_buflen] = ""; string sendbuf2; char recvbuf[default_buflen] = ""; int iresult; int recvbuflen = DEFAULT_BUFLEN; // Validate the parameters if (argc!= 2) { printf("usage: %s server-name\n", argv[0]); // Initialize Winsock iresult = WSAStartup(MAKEWORD(2, 2), &wsadata); if (iresult!= 0) { printf("wsastartup failed with error: %d\n", iresult); ZeroMemory(&hints, sizeof(hints)); hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_STREAM; hints.ai_protocol = IPPROTO_TCP; // Resolve the server address and port iresult = getaddrinfo(argv[1], DEFAULT_PORT, &hints, &result); if (iresult!= 0) { printf("getaddrinfo failed with error: %d\n", iresult); // Attempt to connect to an address until one succeeds for (ptr = result; ptr!= NULL; ptr = ptr->ai_next) { // Create a SOCKET for connecting to server ConnectSocket = socket(ptr->ai_family, ptr->ai_socktype, ptr->ai_protocol); if (ConnectSocket == INVALID_SOCKET) { printf("socket failed with error: %ld\n", WSAGetLastError()); // Connect to server. iresult = connect(connectsocket, ptr->ai_addr, (int)ptr->ai_addrlen); if (iresult == SOCKET_ERROR) { ConnectSocket = INVALID_SOCKET; continue; break; freeaddrinfo(result); if (ConnectSocket == INVALID_SOCKET) { printf("unable to connect to server!\n");
6 int loopthis = 1; while (loopthis == 1) { cout << "Type to say: "; getline(cin, sendbuf2); cout << endl; // Send an initial buffer iresult = send(connectsocket, sendbuf2.c_str(), (int)strlen(sendbuf2.c_str()), 0); if (iresult == SOCKET_ERROR) { printf("send failed with error: %d\n", WSAGetLastError()); printf("bytes Sent: %ld\n", iresult); if (strcmp(sendbuf2.c_str(), "break") == 0) { cout << "exiting...\n"; loopthis = 0; break; // shutdown the connection since no more data will be sent iresult = shutdown(connectsocket, SD_SEND); if (iresult == SOCKET_ERROR) { printf("shutdown failed with error: %d\n", WSAGetLastError()); // Receive until the peer closes the connection do { iresult = recv(connectsocket, recvbuf, recvbuflen, 0); if (iresult > 0) printf("bytes received: %d\n", iresult); else if (iresult == 0) printf("connection closed\n"); else printf("recv failed with error: %d\n", WSAGetLastError()); while (iresult > 0); // cleanup int ok; cin >> ok; return 0;
2007 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 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 informationAssignment description: This is a C++ project. The comms class containing the
Assignment description: This is a C++ project. The comms class containing the code that is common to both the client and server. The classes should contain the functionality required to establishing a
More informationCSE 333 Section 8 - Client-Side Networking
CSE 333 Section 8 - Client-Side Networking Welcome back to section! We re glad that you re here :) Networking Quick Review What are the following protocols used for? (bonus: what layer of the networking
More informationA. Basic Function Calls for Network Communications
IV. Network Programming A. Basic Function Calls for Network Communications 1 B. Settings for Windows Platform (1) Visual C++ 2008 Express Edition (free version) 2 (2) Winsock Header and Libraries Include
More informationUNIX System Programming Lecture 19: IP Sockets
UNIX System Programming Lecture 19: Outline Reference BLP: Chapter 15 man pages: socket, bind, connect, listen, accept, ip(7), ipv6(7), getaddrinfo, getnameinfo 1 Review of UNIX Sockets On the server,
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 informationCSE 333 SECTION 6. Networking and sockets
CSE 333 SECTION 6 Networking and sockets Overview Network Sockets IP addresses and IP address structures in C/C++ DNS Resolving DNS names Demos Section exercise Sockets Network sockets are network interfaces
More information// print product names in alphabetical order with total // number sold of each product using format name: total void PrintTotals();
Question 1. (22 points) STL and C++ classes. Our friends who run the SnackOverflow concession are writing a small program to keep track of the number of items sold. A Sales object contains a
More informationComputer Network Programming
Practical Programming Computer Network Programming Marwan Burelle & David Bouchet david.bouchet.epita@gmail.com 1 Quick Overview 1.IP and Protocol Stack 2.TCP Concepts 3.Client / Server Concepts 4.Socket
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 informationlast time redo logging copy-on-write filesystems / snapshots distributed systems motivation, etc.
Sockets / RPC 1 last time 2 redo logging write log + commit, then do operation on failure, check log redo anything marked committed in log copy-on-write filesystems / snapshots distributed systems motivation,
More informationCSE 333 SECTION 7. Client-Side Network Programming
CSE 333 SECTION 7 Client-Side Network Programming Overview Homework 3 due tonight Questions? Domain Name Service (DNS) Review Client side network programming steps and calls intro dig tool Network programming
More informationClient-side Networking
Client-side Networking CSE 333 Autumn 2018 Instructor: Hal Perkins Teaching Assistants: Tarkan Al-Kazily Renshu Gu Trais McGaha Harshita Neti Thai Pham Forrest Timour Soumya Vasisht Yifan Xu Administriia
More informationCSE 333 Section 3. Thursday 12 April Thursday, April 12, 12
CSE 333 Section 3 Thursday 12 April 2012 Goals for Today 1. Overview IP addresses 2. Look at the IP address structures in C/C++ 3. Overview DNS 4. Talk about how to use DNS to translate IP addresses 5.
More informationAzblink API for Sending XMPP Messages via HTTP POST
Azblink API for Sending XMPP Messages via HTTP POST Abstract: This document is to describe the API of Azblink SBC for sending XMPP messages via HTTP POST. This is intended for the systems or the devices
More informationThe Berkeley Sockets API. Networked Systems Architecture 3 Lecture 4
The Berkeley Sockets API Networked Systems Architecture 3 Lecture 4 The Berkeley Sockets API Widely used low-level C networking API First introduced in 4.3BSD Unix Now available on most platforms: Linux,
More informationCSE 333 SECTION 8. Sockets, Network Programming
CSE 333 SECTION 8 Sockets, Network Programming Overview Domain Name Service (DNS) Client side network programming steps and calls Server side network programming steps and calls dig and ncat tools Network
More informationNetwork Programming in C: The Berkeley Sockets API. Networked Systems 3 Laboratory Sessions
Network Programming in C: The Berkeley Sockets API Networked Systems 3 Laboratory Sessions The Berkeley Sockets API Widely used low-level C networking API First introduced in 4.3BSD Unix Now available
More informationSockets and Parallel Computing. CS439: Principles of Computer Systems April 11, 2018
Sockets and Parallel Computing CS439: Principles of Computer Systems April 11, 2018 Last Time Introduction to Networks OSI Model (7 layers) Layer 1: hardware Layer 2: Ethernet (frames) SAN, LAN, WAN Layer
More informationSecurity impact of noexcept
Security impact of noexcept Project: C++ Programming Language Core Working Group Document Number: N3103-10-0093 Date: 2010-08-23 Authors: David Kohlbrenner, David Svoboda, and Andrew Wesie Abstract In
More informationNetwork Programming in C. Networked Systems 3 Laboratory Sessions and Problem Sets
Network Programming in C Networked Systems 3 Laboratory Sessions and Problem Sets Lab Timetable, Aims, and Objectives Teaching Week Activity 14 Introduction 15 Warm-up exercise 16 17 Web client 18 19 20
More informationCSE 333 SECTION 7. Client-Side Network Programming
CSE 333 SECTION 7 Client-Side Network Programming Overview Domain Name Service (DNS) Client side network programming steps and calls dig and ncat tools Network programming for the client side Recall the
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 informationAppendix B: NET_CON Source Code
B Appendix B: NET_CON Source Code NET_CON.CPP / LSA1000 Sample Network Connection Copyright (c) 1998 LeCroy Corporation Written By: Ricardo Palacio April, 1998 / / $Header:$ $Log:$ / #include
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 informationThe exam is closed book, closed notes, closed electronics, closed telepathy, open mind.
Name There are 7 questions worth a total of 100 points. Please budget your time so you get to all of the questions. Keep your answers brief and to the point. The exam is closed book, closed notes, closed
More informationOutline. Option Types. Socket Options SWE 545. Socket Options. Out-of-Band Data. Advanced Socket. Many socket options are Boolean flags
Outline SWE 545 Socket Options POSIX name/address conversion Out-of-Band Data Advanced Socket Programming 2 Socket Options Various attributes that are used to determine the behavior of sockets Setting
More informationWindows Socket Modern System Calls & Concurrent, Connection-Oriented Servers. Prof. Lin Weiguo Copyleft 2009~2015, College of Computing, CUC
Windows Socket Modern System Calls & Concurrent, Connection-Oriented Servers Prof. Lin Weiguo Copyleft 2009~2015, College of Computing, CUC Nov 2015 Note } You should not assume that an example in this
More informationSockets. Dong-kun Shin Embedded Software Laboratory Sungkyunkwan University Embedded Software Lab.
1 Sockets Dong-kun Shin Embedded Software Laboratory Sungkyunkwan University http://nyx.skku.ac.kr Echo Client (1) 2 #include #include #include #include
More informationEECS 123: Introduction to Real-Time Distributed Programming
EECS 123: Introduction to Real-Time Distributed Programming Lecture : IP, UDP, TCP, RPC, and Time Measurement This slide-set was prepared by the Teaching Assistant, P. Athreya. * Most of the slides in
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 informationCSE 333 SECTION 7. C++ Virtual Functions and Client-Side Network Programming
CSE 333 SECTION 7 C++ Virtual Functions and Client-Side Network Programming Overview Virtual functions summary and worksheet Domain Name Service (DNS) Client side network programming steps and calls dig
More informationModern System Calls(IPv4/IPv6)
Windows Socket Modern System Calls(IPv4/IPv6) 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
More informationLinked List using a Sentinel
Linked List using a Sentinel Linked List.h / Linked List.h Using a sentinel for search Created by Enoch Hwang on 2/1/10. Copyright 2010 La Sierra University. All rights reserved. / #include
More informationWrite your answer on the next page. You may remove this page for reference while working if you wish.
Question 1. (20 points) A bit of C++ hacking STL version The question that is a lot longer than the answer. It s a social media world and Twitter wants you to digest some data that they have. Write a program
More informationIntroduction to Lab 2 and Socket Programming. -Vengatanathan Krishnamoorthi
Introduction to Lab 2 and Socket Programming -Vengatanathan Krishnamoorthi Before we start.. Soft deadline for lab 2- February 13 Finish assignment 1 as soon as possible if you have not yet. Hard deadline
More informationRedesde Computadores(RCOMP)
Redesde Computadores(RCOMP) Theoretical-Practical (TP) Lesson 06 2016/2017 Berkeley sockets API, C and Java. Address families and address storing. Basic functions/methods for UDP applications. UDP client
More information518 Lecture Notes Week 12
518 Lecture Notes Week 12 (November 16, 2014) 1/13 518 Lecture Notes Week 12 1 Topics TCP/IP C programing for sockets 2 TCP/IP The socket call (socket_create.c) int main(int argc, char *argv[]) int socket_desc;
More informationPorting IPv4 applications to IPv4/v6 dual stack. Owen DeLong
Porting IPv4 applications to IPv4/v6 dual stack Owen DeLong owend@he.net Revised 10/17/2009 Hurricane Electric Why is this important? 2 Apologies in advance for the Text-Fest Text Text Text Text Text Text
More informationJFx Joystick. June 21, Unrestricted Distribution. Revision 1.00
JFx Joystick TCP Software Interface Revision 1.00 June 21, 2011 Unrestricted Distribution Table of Contents 1 Document Purpose 2 1.1 Conventions 2 2 Software 3 2.1 Startup 3 2.1.1 Initialization 3 2.1.2
More informationCSCI 4061: Sockets and Network Programming
1 CSCI 4061: Sockets and Network Programming Chris Kauffman Last Updated: Tue Dec 5 13:30:56 CST 2017 Networks are Aging Source: www.ipv6now.hk Source: XKCD #865 2 3 Aging Networks Makes Network Programming
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 informationComputer Network Lab, SS Fachgebiet Technische Informatik, Joachim Zumbrägel. Overview. Sockets. Sockets in C.
Computer Network Lab 2016 Fachgebiet Technische Informatik, Joachim Zumbrägel Overview Sockets Sockets in C Sockets in Delphi 1 Inter process communication There are two possibilities when two processes
More informationIP Addresses, DNS. CSE 333 Spring Instructor: Justin Hsia
IP Addresses, DNS CSE 333 Spring 2018 Instructor: Justin Hsia Teaching Assistants: Danny Allen Dennis Shao Eddie Huang Kevin Bi Jack Xu Matthew Neldam Michael Poulain Renshu Gu Robby Marver Waylon Huang
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 informationSystem Programming. Sockets: examples
Content : by Dr. B. Boufama School of Computer Science University of Windsor Instructor: Dr. A. Habed adlane@cs.uwindsor.ca http://cs.uwindsor.ca/ adlane/60-256 Content Content 1 Socket based client/server
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 informationCSCI 4210 Operating Systems CSCI 6140 Computer Operating Systems Sample Exam 2 Questions (document version 1.0)
CSCI 4210 Operating Systems CSCI 6140 Computer Operating Systems Sample Exam 2 Questions (document version 1.0) Overview Exam 2 will be in class on Thursday, April 13, 2017 from 10:00-11:45AM (please arrive
More informationAdapting Data for Web Applications That Use IPv6 Internet Protocol
American Association for Science and Technology AASCIT Communications Volume 1, Issue 3 October 20, 2014 online Adapting Data for Web Applications That Use IPv6 Internet Protocol Dănuţ-Octavian Simion
More informationCSE 124 Discussion Section Sockets Programming 10/10/17
CSE 124 Discussion Section Sockets Programming 10/10/17 Topics What s a socket? Creating a socket Connecting a socket Sending data Receiving data Resolving URLs to IPs Advanced socket options Live code
More informationPA #2 Reviews. set_name, get_name, del_name. Questions? Will be modified after PA #4 ~
Sockets Prof. Jin-Soo Kim( jinsookim@skku.edu) TA Dong-Yun Lee(dylee@csl.skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu PA #2 Reviews set_name, get_name, del_name Will
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 informationCS2141 Software Development using C/C++ C++ Basics
CS2141 Software Development using C/C++ C++ Basics Integers Basic Types Can be short, long, or just plain int C++ does not define the size of them other than short
More informationSocket Programming. #In the name of Allah. Computer Engineering Department Sharif University of Technology CE443- Computer Networks
#In the name of Allah Computer Engineering Department Sharif University of Technology CE443- Computer Networks Socket Programming Acknowledgments: Lecture slides are from Computer networks course thought
More informationMessage passing systems are popular because they support client-server interactions, where: clients send messages to servers requesting a server.
Client-Server Model Message passing systems are popular because they support client-server interactions, where: clients send messages to servers requesting a server. servers provide services requested
More informationCS 43: Computer Networks. 05: Socket Programming September 12-14, 2018
CS 43: Computer Networks 05: Socket Programming September 12-14, 2018 Reading Quiz Lecture 5/6 - Slide 2 Socket Programming Adapted from: Donahoo, Michael J., and Kenneth L. Calvert. TCP/IP sockets in
More informationCSC209H Lecture 10. Dan Zingaro. March 18, 2015
CSC209H Lecture 10 Dan Zingaro March 18, 2015 Creating a Client To create a client that can connect to a server, call the following, in order: socket: create a communication endpoint This is the same as
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 informationAgenda. The main body and cout. Fundamental data types. Declarations and definitions. Control structures
The main body and cout Agenda 1 Fundamental data types Declarations and definitions Control structures References, pass-by-value vs pass-by-references The main body and cout 2 C++ IS AN OO EXTENSION OF
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 informationCSCI 415 Computer Networks Homework 2 Due 02/13/08
CSCI 415 Computer Networks Homework 2 Due 02/13/08 Saad Mneimneh Computer Science Hunter College of CUNY Problem 1 Consider the following server and client C++ code that we saw in class: server.c #include
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 informationECE 435 Network Engineering Lecture 2
ECE 435 Network Engineering Lecture 2 Vince Weaver http://web.eece.maine.edu/~vweaver vincent.weaver@maine.edu 31 August 2017 Announcements Homework 1 will be posted. Will be on website, will announce
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 informationSockets. Dong-kun Shin Embedded Software Laboratory Sungkyunkwan University Embedded Software Lab.
1 Sockets Dong-kun Shin Embedded Software Laboratory Sungkyunkwan University http://nyx.skku.ac.kr Internet Connections (1) 2 Connection Clients and servers communicate by sending streams of bytes over
More informationCWRU High-Speed Flexible Parts Feeder. Software Source Code
CWRU High-Speed Flexible Parts Feeder Software Source Code Source File List Overall Control master_control_loop.h master_control_loop.cpp main_control.h main_control.cpp main_control_sub_systems.cpp main_control_update_users.cpp
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 informationCA341 - Comparative Programming Languages
CA341 - Comparative Programming Languages David Sinclair Dynamic Data Structures Generally we do not know how much data a program will have to process. There are 2 ways to handle this: Create a fixed data
More informationCS4514 B08 HELP Session 1
CS4514 B08 HELP Session 1 Presented by Choong-Soo Lee clee01@cs.wpi.edu CS4514 TCP/IP Socket Programming Outline Project 1 Overview Unix Network Programming TCP Client TCP Server Processing commands How
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 informationIP Addresses, DNS. CSE 333 Summer Teaching Assistants: Renshu Gu William Kim Soumya Vasisht
IP Addresses, DNS CSE 333 Summer 2018 Instructor: Hal Perkins Teaching Assistants: Renshu Gu William Kim Soumya Vasisht Lecture Outline Network Programming Sockets API Network Addresses DNS Lookup 2 Files
More informationGetting Familiar with CCN
Getting Familiar with CCN 1 Project Goal In this project you will experiment with simple client/server programs in CCN to familiarize yourselves with the CCN basics. You will compile, run, and answer the
More informationNetworks and Their Abstractions. CS439: Principles of Computer Systems April 9, 2018
Networks and Their Abstractions CS439: Principles of Computer Systems April 9, 2018 Where We Are In The Course We ve done: Processes Threads Synchronization Virtual Memory File Systems Disks We have our
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 informationCS4514 (C04) HELP Session 1 Introduction to Network Programming (v1.3)
CS4514 (C04) HELP Session 1 Introduction to Network Programming (v1.3) Speaker: Frank Posluszny Outline! Project 1 Overview! Unix Network Programming Client Server Communication with netoracle! Project
More informationCSE 333 Lecture 16 - network programming intro
CSE 333 Lecture 16 - network programming intro Hal Perkins Department of Computer Science & Engineering University of Washington Today Network programming - dive into the Berkeley / POSIX sockets API -
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 informationA Case Study of IPv6 Deployment in tcd.ie
A Case Study of IPv6 Deployment in tcd.ie David Malone 22 May 2003 1 What is IPv6? 1. Current version of IP is version 4. 2. IPv6 is an evolution of IPv4. 3. Not backwards
More informationCS 4400 Fall 2017 Final Exam Practice
CS 4400 Fall 2017 Final Exam Practice Name: Instructions You will have eighty minutes to complete the actual open-book, opennote exam. Electronic devices will be allowed only to consult notes or books
More informationCisco CallManager 4.0(1) AXL API Programming Guide
Cisco CallManager 4.0(1) AXL API Programming Guide NOTE: To access all AXL SOAP API downloads and AXL requests and responses found in this document, please refer to the following url: http://www.cisco.com/warp/public/570/avvid/voice_ip/axl_soap/axl_api_down.html
More information// Embedded Systems // BeagleBoard-XM. // Author : Jose Goncalves //
// Embedded Systems // BeagleBoard-XM // Author : Jose Goncalves // jose.braga.pt@gmail.com // Teacher : Nuno Peixoto // University : IPCA // 17.03.2014 #include #include #include
More information#include <iostream> #include <algorithm> #include <cmath> using namespace std; int f1(int x, int y) { return (double)(x/y); }
1. (9 pts) Show what will be output by the cout s in this program. As in normal program execution, any update to a variable should affect the next statement. (Note: boolalpha simply causes Booleans to
More informationUnix Network Programming Chapter 4. Elementary TCP Sockets 광운대학교컴퓨터과학과 정보통신연구실 석사과정안중현
Unix Network Programming Chapter 4. Elementary TCP Sockets 광운대학교컴퓨터과학과 정보통신연구실 석사과정안중현 4.1 Introduction A Time line of the typical scenario that takes place between a TCP client and server. Describes the
More informationProject 3. Reliable Data Transfer over UDP. NTU CSIE Computer Networks 2011 Spring
Project 3 Reliable Data Transfer over UDP NTU CSIE Computer Networks 2011 Spring Project Goal In Project 3, students are asked to understand and implement reliable data transfer mechanism over UDP. UDP
More informationCategory: Informational J. Bound J. McCann Hewlett-Packard W. Stevens February 2003
Network Working Group Request for Comments: 3493 Obsoletes: 2553 Category: Informational R. Gilligan Intransa, Inc. S. Thomson Cisco J. Bound J. McCann Hewlett-Packard W. Stevens February 2003 Status of
More informationJordan University of Science & Technology Department of Computer Science CS 211 Exam #1 (23/10/2010) -- Form A
Jordan University of Science & Technology Department of Computer Science CS 211 Exam #1 (23/10/2010) -- Form A Name: ID#: Section #: Day & Time: Instructor: Answer all questions as indicated. Closed book/closed
More informationECE 435 Network Engineering Lecture 2
ECE 435 Network Engineering Lecture 2 Vince Weaver http://web.eece.maine.edu/~vweaver vincent.weaver@maine.edu 6 September 2018 Announcements Homework 1 will be posted. Will be on website, will announce
More informationTCP Echo Application: Client & Server. TA: Awad A Younis Class: CS457 Fall 2014
TCP Echo Application: Client & Server TA: Awad A Younis Class: CS457 Fall 2014 Outline Echo Server TCP-Client TCP-Server 2 Echo Server The server simply echo whatever it receives back to the client Echo:
More informationNetwork Programming Week #1. K.C. Kim
Network Programming Week #1 K.C. Kim kckim@konkuk.ac.kr How do we communicate? Mail Example 1. Write a mail 2. Put the mail into a mailbox 3. Post office classify mails based on the address 4. Cars, airplanes
More informationPiotr Mielecki Ph. D.
Piotr Mielecki Ph. D. http://mielecki.ristel.pl/ piotr.mielecki@pwr.edu.pl pmielecki@gmail.com Building blocks of client-server applications: Client, Server, Middleware. Simple client-server application:
More informationChapter 2 Applications and
Chapter 2 Applications and ed Architectures Protocols, Services & ing OSI Reference Model TCP/IP Architecture How the s Work Together Berkeley Sockets Application Protocols & Utilities 1 s, Services &
More information6 장과제샘플코드 - 다자간채팅 (udp 버전 1) 목포해양대해양컴퓨터공학과
6 장과제샘플코드 - 다자간채팅 (udp 버전 1) 과제 서버에서먼저 bind 하고그포트를다른사람에게알려줄것 클라이언트들은알려준포트로접속 서버는클라이언트로부터받은메시지를다른클라이언트들에게전달 2 Makefile 1 SRC_DIR =../../common 2 COM_OBJS = $(SRC_DIR)/addressUtility.o $(SRC_DIR)/dieWithMessage.o
More informationIPv6 Porting Applications
IPv6 Porting Applications US IPv6 Summit Dec 8-11, 8 2003 Eva M. Castro eva@gsyc.escet.urjc.es Systems and Communications Group (GSyC( GSyC) Experimental Sciences and Technology Department (ESCET) Rey
More information목포해양대해양컴퓨터공학과. IPv6 적용
IPv6 적용 1 IPV6 기본규격 2 IPv6 Basic header 3 IPv6 - Extension Headers (1) Hop-by-Hop Options (0) RSVP, PIM/MLD, etc. Routing (43) Source Routing, MIPv6 Fragment (44) Encapsulating Security Payload (50) IPsec
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 informationCommon Misunderstandings from Exam 1 Material
Common Misunderstandings from Exam 1 Material Kyle Dewey Stack and Heap Allocation with Pointers char c = c ; char* p1 = malloc(sizeof(char)); char** p2 = &p1; Where is c allocated? Where is p1 itself
More informationFountain Multimedia Broadcasting Final Report Spring Semester 2012
Fountain Multimedia Broadcasting Final Report Spring Semester 2012 -Full Report- By Aqeel Alhashim Ben Kappel Jassim Alhashim Prepared to partially fulfill the requirements for ECE402 Department of Electrical
More informationThe Transport Layer. The need for the transport layer
The Transport Layer Aims To explain:- The need for the transport layer A simple exemplar Transport in IP and ATM Outcomes To understand the need for the layer and the solution adopted adopted when internetworking
More information