Internet Applications and Network Programming

Slides:



Advertisements
Similar presentations
Introduction to Sockets Jan Why do we need sockets? Provides an abstraction for interprocess communication.
Advertisements

Data Communications and Networking (Third Edition)
Socket Programming.
1 Java Networking – Part I CS , Spring 2008/9.
1 L53 Networking (2). 2 OBJECTIVES In this chapter you will learn:  To understand Java networking with URLs, sockets and datagrams.  To implement Java.
1 Generic Transport Service Primitives Listen –notify Transport layer a call is expected Connect –establish Transport layer connection Send (or Write)
CS3771 Today: network programming with sockets  Previous class: network structures, protocols  Next: network programming Sockets (low-level API) TODAY!
McGraw-Hill©The McGraw-Hill Companies, Inc., 2004 Application Layer PART VI.
Client Server Model The client machine (or the client process) makes the request for some resource or service, and the server machine (the server process)
I NTRODUCTION OF S OCKET P ROGRAMMING L.Aseel AlTurki King Saud University.
Chapter 26 Client Server Interaction Communication across a computer network requires a pair of application programs to cooperate. One application on one.
UNIX Sockets COS 461 Precept 1. Clients and Servers Client program – Running on end host – Requests service – E.g., Web browser Server program – Running.
Process-to-Process Delivery:
Socket Programming -What is it ? -Why bother ?. Basic Interface for programming networks at transport level It is communication end point Used for inter.
Dr. John P. Abraham Professor University of Texas Pan American Internet Applications and Network Programming.
TCP/IP protocols Communication over Internet is mostly TCP/IP (Transmission Control Protocol over Internet Protocol) TCP/IP "stack" is software which allows.
Chapter 17 Networking Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William Stallings.
NET0183 Networks and Communications Lecture 31 The Socket API 8/25/20091 NET0183 Networks and Communications by Dr Andy Brooks Lecture powerpoints from.
1 Chapter Client-Server Interaction. 2 Functionality  Transport layer and layers below  Basic communication  Reliability  Application layer.
 Socket  The combination of an IP address and a port number. (RFC 793 original TCP specification)  The name of the Berkeley-derived application programming.
Windows Programming Using C# Internet Programming.
Transport Layer Layer #4 (OSI-RM). Transport Layer Main function of OSI Transport layer: Accept data from the Application layer and prepare it for addressing.
Jozef Goetz, Application Layer PART VI Jozef Goetz, Position of application layer The application layer enables the user, whether human.
Internet Applications and Network Programming Dr. Abraham Professor UTPA.
ICOM 6115©Manuel Rodriguez-Martinez ICOM 6115 – Computer Networks and the WWW Manuel Rodriguez-Martinez, Ph.D. Lecture 26.
Introduction to Network Programming with Sockets Network Programming Kansas State University at Salina.
RGEC MEERUT(IWT CS703) 1 Java Networking RGEC Meerut.
Dr. John P. Abraham Professor University of Texas Pan American Internet Applications and Network Programming.
Chapter 2 Applications and Layered Architectures Sockets.
The Socket Interface Chapter 21. Application Program Interface (API) Interface used between application programs and TCP/IP protocols Interface used between.
UDP Client-Server. The Socket Class The Socket class provides a set of methods and properties for network communications. The Socket class allows you.
Network Programming with C# Exceed Camp #2, CPE, KU Day 3.
CS 158A1 1.4 Implementing Network Software Phenomenal success of the Internet: – Computer # connected doubled every year since 1981, now approaching 200.
TELE202 Lecture 15 Socket programming 1 Lecturer Dr Z. Huang Overview ¥Last Lecture »TCP/UDP (2) »Source: chapter 17 ¥This Lecture »Socket programming.
Chapter 27 Socket API Interface The interface between an application program and the communication protocols in an operating system is known as the Application.
1 Client-Server Interaction. 2 Functionality Transport layer and layers below –Basic communication –Reliability Application layer –Abstractions Files.
Socket Programming Introduction. Socket Definition A network socket is one endpoint in a two-way communication flow between two programs running over.
The Client-Server Model And the Socket API. Client-Server (1) The datagram service does not require cooperation between the peer applications but such.
CSI 3125, Preliminaries, page 1 Networking. CSI 3125, Preliminaries, page 2 Networking A network represents interconnection of computers that is capable.
UNIT-6. Basics of Networking TCP/IP Sockets Simple Client Server program Multiple clients Sending file from Server to Client Parallel search server.
1 CSCD 330 Network Programming Fall 2013 Some Material in these slides from J.F Kurose and K.W. Ross All material copyright Lecture 8a Application.
MT311 Java Application Development and Programming Languages Li Tak Sing ( 李德成 )
Agenda Socket Programming The OSI reference Model The OSI protocol stack Sockets Ports Java classes for sockets Input stream and.
The OSI Model. Understanding the OSI Model In early 1980s, manufacturers began to standardize networking so that networks from different manufacturers.
1 Network Communications A Brief Introduction. 2 Network Communications.
1 K. Salah Application Layer Module K. Salah Network layer duties.
SOCKET PROGRAMMING Presented By : Divya Sharma.
Application Layer Functionality and Protocols Abdul Hadi Alaidi
Object-Orientated Analysis, Design and Programming
Networking Based Applications
Sockets and Beginning Network Programming
Chapter 3 Internet Applications and Network Programming
MCA – 405 Elective –I (A) Java Programming & Technology
Socket Programming Cal Poly Pomona Young CS380.
Socket Programming in C
Socket Interface 1 Introduction 11 Socket address formats 2 API 12 13
Client/Server Example
Client-Server Interaction
Interacting With Protocol Software
Socket programming - Java
Process-to-Process Delivery:
27.
TCP/IP Protocol Suite: Review
Chapter 2 Application Layer
PART 5 Transport Layer.
Internet Applications & Programming
Kyle Broussard, Alexandra Mikolai,
Process-to-Process Delivery: UDP, TCP
Computer Networks Protocols
Exceptions and networking
Presentation transcript:

Internet Applications and Network Programming Dr. Abraham Professor UTPA

Basics of socket programming Server program Client Program

Server Program Create a socket with the socket() system call Bind the socket to an address using the bind() system call. For a server socket on the Internet, an address consists of a port number on the host machine. Each application should use a unique port. Listen for connections with the listen() system call Accept a connection with the accept() system call. This call typically blocks until a client connects with the server. Send and receive data

Client Program Create a socket with the socket() system call Connect the socket to the address of the server using the connect() system call Send and receive data. There are a number of ways to do this, but the simplest is to use the read() and write() system calls.

Communication Paradigms

Stream

Connection of Oriented Communication (TCP) Stream service First connection must be established Data may be send in either direction Finish communication Applications request connection terminated.

Client-server model of interaction The server application starts first and waits for client to connect Client starts next and initiates connection

Server application Starts first Does not need to know which client will contact it (so need to know client IP) Waits passively Communicates with a client by sending and receiving data When one client finished, waits for another.

Client application Starts second Must know the IP of the intended server. Initiates contact with the server when communication is needed. Sends and receives data between server and the client May terminate after interacting with the server or contact another server

Server Identification Identify Computer IP address, or use DNS to obtain IP Identify Process 16 bit protocol port number. Well known or ephemeral

SOME WELL KNOWN PORTS SERVICE PORT HTTP 80 POP3 110 SMTP 25 TELNET 23 FTP 21,20 FINGER 79 LOCAL LOOPS

SOCKET APPLICATION PROGRAMMER’S INTERFACE (API) TO THE NETWORK (TRANSPORT LAYER) The socket API is integrated with I/O When an application creates a socket to use for Internet communication, the OS returns a small integer descriptor that identifies the socket The application then passes the descriptor as an argument when it calls functions to perform an operation on the socket

TCP or UDP THE TRANSPORT PROTOCOL CAN USE EITHER TCP OR UDP PROGRAMMER NEEDS TO SPECIFY WHICH IS BEING USED

C# (.NET) The .NET framework provides two namespaces, System.Net and System.Net.Sockets for socket programming. The communication can be either connection oriented or connectionless. They can also be either stream oriented or data-gram based. The most widely used protocol TCP is used for stream-based communication and UDP is used for data-grams based applications.  .

Discovering IP address System.Net contains the Dns class. Dns class can be used to query information about various things including the IP addresses Dns.GetHostByName can be used to return DNS host name of the local machine. Here is an example of this program. You will have to write this program yourself, so I am only showing the executable program.

Sample program in c# to resolve address given a host name using System; using System.Net; using System.Net.Sockets; class SocketAddress { public static void Main() IPHostEntry IPHost = Dns.Resolve("www.utpa.edu"); Console.WriteLine(IPHost.HostName); string []aliases = IPHost.Aliases; IPAddress[] addr = IPHost.AddressList; for(int i= 0; i < addr.Length ; i++) Console.WriteLine(addr[i]); } Console.ReadKey();

Explanation IPHostEntry IPHost = Dns.Resolve("www.utpa.edu"); The Resolve method queries a DNS server for the IP address associated with a host name or IP address. IPHost.Aliases gives any aliases associated with that host name. This can be stored in an array. IPHost.AddressList will provide addresses associated with the hostname. They can be stored in an array.

Another Program using System; using System.Net; using System.Net.Sockets; class MyClient { public static void Main() IPHostEntry IPHost = Dns.Resolve("www.ebay.com"); Console.WriteLine(IPHost.HostName); string[] aliases = IPHost.Aliases; Console.WriteLine(aliases.Length); IPAddress[] addr = IPHost.AddressList; Console.WriteLine(addr.Length); for (int i = 0; i < addr.Length; i++) Console.WriteLine(addr[i]); } Console.ReadKey();

Sample program (in VB) Private Sub Form_Load() ' Set the LocalPort property to an integer. ‘ Then invoke the Listen method. tcpServer.LocalPort = 1001 tcpServer.Listen frmClient.Show ' Show the client form. End Sub Private Sub tcpServer_ConnectionRequest _ (ByVal requestID As Long) ' Check if the control's State is closed. If not, ' close the connection before accepting the new ' connection. If tcpServer.State <> sckClosed Then _ tcpServer.Close ' Accept the request with the requestID ' parameter. tcpServer.Accept requestID End Sub Private Sub txtSendData_Change() ' The TextBox control named txtSendData ' contains the data to be sent. Whenever the user ' types into the  textbox, the  string is sent ' using the SendData method. tcpServer.SendData txtSendData.Text End Sub Private Sub tcpServer_DataArrival _ (ByVal bytesTotal As Long) ' Declare a variable for the incoming data. ' Invoke the GetData method and set the Text ' property of a TextBox named txtOutput to ' the data. Dim strData As String tcpServer.GetData strData txtOutput.Text = strData

Lab Assignments to come Write a program to discover IP addresses Write server and client programs to send some text Optional for extra credit Write a chat program using multithreading. .