Technical Details for sockaddr_in Structure Department of Computer Science Southern Illinois University Edwardsville Fall, 2015 Dr. Hiroshi Fujinoki E-mail:

Slides:



Advertisements
Similar presentations
Elementary TCP Sockets Computer Networks Computer Networks Term B10 UNIX Network Programming Vol. 1, Second Ed. Stevens Chapter 4.
Advertisements

Networks: TCP/IP Socket Calls1 Elementary TCP Sockets Chapter 4 UNIX Network Programming Vol. 1, Second Ed. Stevens.
Quick Overview. 2 ISO/OSI Reference Model Application Application Presentation Presentation Session Session Transport Transport Network Network Data Link.
תקשורת באינטרנט Tutorial 8. 2 n Socket programming u What is socket ? u Sockets architecture u Types of Sockets u The Socket system calls u Data Transfer.
Sockets Programming Introduction © Dr. Ayman Abdel-Hamid, CS4254 Spring CS4254 Computer Network Architecture and Programming Dr. Ayman A. Abdel-Hamid.
Tutorial 8 Socket Programming
CS 311 – Lecture 19 Outline Internet Sockets – gethostname utility – struct hostent – inet_addr – Machine byte to Network byte order translation and vice.
UDP: User Datagram Protocol. UDP: User Datagram Protocol [RFC 768] r “bare bones”, “best effort” transport protocol r connectionless: m no handshaking.
CS 311 – Lecture 18 Outline IPC via Sockets – Server side socket() bind() accept() listen() – Client side connect() Lecture 181CS Operating Systems.
1 Example (UDP Client) // This program sends UDP packets to the given address #include #define SERVER_ADDR " " #define SERVER_PORT 5555 void error(char.
Socket Addresses. Domains Internet domains –familiar with these Unix domains –for processes communicating on the same hosts –not sure of widespread use.
Winsock programming.  TCP/IP UDP TCP  Winsock #include wsock32.lib.
Unix Network Programming Part 2: Elementary Sockets Jani Peusaari.
TCP Socket Programming. r An abstract interface provided to the application programmer  File descriptor, allows apps to read/write to the network r Allows.
1 Tutorial on Socket Programming Computer Networks - CSC 458 Department of Computer Science Yukun Zhu (Slides are mainly from Monia Ghobadi, and Amin Tootoonchian,
Networking S04, Recitation, Section A
TCP Socket Programming. r An abstract interface provided to the application programmer  File descriptor, allows apps to read/write to the network r Allows.
Operating Systems Chapter 9 Distributed Communication.
CS345 Operating Systems Φροντιστήριο Άσκησης 2. Inter-process communication Exchange data among processes Methods –Signal –Pipe –Sockets.
CS 447 Networks and Data Communication
Sirak Kaewjamnong Computer Network Systems
Server Sockets: A server socket listens on a given port Many different clients may be connecting to that port Ideally, you would like a separate file descriptor.
Department of Computer Science Southern Illinois University Edwardsville Spring, 2008 Dr. Hiroshi Fujinoki FTP Protocol Programming.
1 Writing Network Applications using the TCP/IP Protocol Stack: Socket Programming.
CS 447 Networks and Data Communication ARP (Address Resolution Protocol) for the Internet Department of Computer Science Southern Illinois University Edwardsville.
Lab 5 Sockets. Useful Sockets Links (courtesy of Stanford University) Programming UNIX Sockets in C - Frequently Asked Questions
The Pocket Guide to TCP/IP Sockets: C Version Michael J. Donahoo Kenneth L. Calvert.
Outline Socket programming with Windows OSSocket programming with Windows OS C++ UDPSocket classC++ UDPSocket class Socket programming with Windows OSSocket.
Networking Tutorial Special Interest Group for Software Engineering Luke Rajlich.
1 Computer Networks An Introduction to Computer Networks University of Tehran Dept. of EE and Computer Engineering By: Dr. Nasser Yazdani Lecture 3: Sockets.
TELE202 Lecture 15 Socket programming 1 Lecturer Dr Z. Huang Overview ¥Last Lecture »TCP/UDP (2) »Source: chapter 17 ¥This Lecture »Socket programming.
University of Calgary – CPSC 441.  A socket is an interface between the application and the network (the lower levels of the protocol stack)  The application.
Elementary TCP Sockets UNIX Network Programming Vol. 1, Second Ed. Stevens Chapter 4.
Introduction to Socket
Socket Programming Tutorial Department of Computer Science Southern Illinois University Edwardsville Fall, 2015 Dr. Hiroshi Fujinoki
Socket Programming Lab 1 1CS Computer Networks.
1 Sockets Programming Socket to me!. 2 Network Application Programming Interface (API) The services provided by the operating system that provide the.
Socket address structures Byte ordering IP address conversion
Read() recv() connection establishment Server (connection-oriented protocol) blocks until connection from client Client socket() bind() listen() accept()
2: Application Layer 1 Socket Programming UNIX Network Programming, Socket Programming Tutorial:
CSCI 330 UNIX and Network Programming Unit XIV: User Datagram Protocol.
In unistd.h : int gethostname(char * name, int maxlen) Purpose : Find the computer's name.
Socket Programming. Computer Science, FSU2 Interprocess Communication Within a single system – Pipes, FIFOs – Message Queues – Semaphores, Shared Memory.
1 Spring Semester 2008, Dept. of Computer Science, Technion Internet Networking recitation #7 Socket Programming.
Advanced UNIX programming Fall 2002 Instructor: Ashok Srinivasan Lecture 17 Acknowledgements: The syllabus and power point presentations are modified versions.
Department of Computer Science Southern Illinois University Edwardsville Spring, 2010 Dr. Hiroshi Fujinoki CS 547/490 Network.
CS 447 Networks and Data Communication Server-Process Organization IP address and SockAddr_In Data Structure Department of Computer Science Southern Illinois.
Socket Programming in C CS587x Lecture 3 Department of Computer Science Iowa State University.
Socket Programming(1/2). Outline  1. Introduction to Network Programming  2. Network Architecture – Client/Server Model  3. TCP Socket Programming.
Client-Server model. Socket programming 
Jim Fawcett CSE 681 – Software Modeling & Analysis Fall 2002
Socket Programming (Cont.)
The Pocket Guide to TCP/IP Sockets: C Version
Network Programming CSC- 341
Week 13 - Friday CS222.
Network Programming with Sockets
Socket Interface 1 Introduction 11 Socket address formats 2 API 12 13
Transport layer API: Socket Programming
Things that are nice to know when you’re doing this project
Recitation 11 – 4/29/01 Outline Sockets Interface
Socket Programming.
Introduction to Berkeley Sockets
Chapter 3 Socket API © Bobby Hoggard, Department of Computer Science, East Carolina University These slides may not be used or duplicated without permission.
Refs: Chapter 10, Appendix A
Socket Programming(1/2)
Sockets Programming Socket to me!.
Sockets Programming Socket to me!.
Internet Networking recitation #8
in unistd.h: int gethostname(char * name, int maxlen)
CSI 4118 – UNIVERSITY OF OTTAWA
Presentation transcript:

Technical Details for sockaddr_in Structure Department of Computer Science Southern Illinois University Edwardsville Fall, 2015 Dr. Hiroshi Fujinoki CS447 - Computer and Data Communication SockAddr_Structure.ppt/000

CS447 - Computer and Data Communication How to specify your destination in socket? Server Host Client Host X IP Address Server Process Port # Each destination for a socket connection is determined by SockAddr_Structure.ppt/001

CS447 - Computer and Data Communication struct sockaddr_in { u_char sin_len; /* Length of this structure */ u_char sin_family; /* Network protocol used*/ u_short sin_port; /* Port number */ struct in_addr sin_addr; /* Pointer to an IP address */ char sin_zero[8]; /* Extra information */ }; How to specify your destination in our socket program source code? struct in_addr { u_long s_addr; /* Actual IP address */ }; sockaddr_in structure is used to define your destination The sockaddr_in structure is defined in C/C++ struct The sockaddr_in structure is defined in windows.h header file

CS447 - Computer and Data Communication How to specify your destination in our socket program source code (part 2)? An instance of sockaddr_in structure in memory Structure length (in bytes) Network-layer protocol Port number Pointer to in_addr structure Extra information An instance of in_addr structure in memory IP address as a binary number (32 bits) SockAddr_Structure.ppt/004

CS447 - Computer and Data Communication How to specify your destination in our socket program source code (part 3)? An instance of sockaddr_in structure in memory 128 IP protocol 1050 Extra information An instance of in_addr structure in memory SockAddr_Structure.ppt/005

CS447 - Computer and Data Communication struct sockaddr_in server_address; How to specify your destination in our socket program source code (part 4)? How can I set the IP address and the port number of my destination? STEP #1: Instantiate a sockaddr_in structure: STEP #2: Set your destination IP address: Case 1: by “32-bit IP address” server_address.sin_addr.s_addr = inet_addr(“ ”); Case 2: by a host name server_address.sin_addr.s_addr = inet_aton(“cougar.siue.edu”); Case 3: by a system-defined parameter server_address.sin_addr.s_addr = htonl(INADDR_ANY); SockAddr_Structure.ppt/006

CS447 - Computer and Data Communication How to specify your destination in our socket program source code (part 4)? How can I set the IP address and the port number of my destination? STEP #3: Set your destination port number: server_address.sin_port = htons(80); You are connecting to port #80! SockAddr_Structure.ppt/007

CS447 - Computer and Data Communication Example of setting IP address and port number SockAddr_Structure.ppt/008 #define SERVER_IP " “ /* Server IP address */ #define SERVER_PORT 8050 /* Server-side port # */ struct sockaddr_in server_addr; /* Server Internet address */ /* Set Server's IP Address */ server_addr.sin_family = AF_INET; /* Address Family to be Used */ server_addr.sin_addr.s_addr = inet_addr(SERVER_IP); /* IP address */ server_addr.sin_port = htons(int(SERVER_PORT));/* Port num to use */   