PRESENTED To: Sir Abid………. PRESENTED BY: Insharah khan………. SUBJECT:

Slides:



Advertisements
Similar presentations
Socket Programming ENTERPRISE JAVA. 2 Content  Sockets  Streams  Threads  Readings.
Advertisements

Sockets for Clients Socket Basics  Connect to a remote machine  Send data  Receive data  Close a connection  Bind to a port 
Using TCP sockets in Java Created by M Bateman, A Ruddle & C Allison As part of the TCP View project.
Socket Programming By Ratnakar Kamath. What Is a Socket? Server has a socket bound to a specific port number. Client makes a connection request. Server.
Prepared By E. Musa Alyaman1 Java Network Programming TCP.
Basic Socket Programming with Java. What is a socket?  Generally refers to a stream connecting processes running in different address spaces (across.
1 Java Networking – Part I CS , Spring 2008/9.
WECPP1 Java networking Jim Briggs based on notes by Amanda Peart based on Bell & Parr's bonus chapter
1 L53 Networking (2). 2 OBJECTIVES In this chapter you will learn:  To understand Java networking with URLs, sockets and datagrams.  To implement Java.
Client/Server In Java An Introduction to TCP/IP and Sockets.
13-Jul-15 Sockets and URLs. 2 Sockets A socket is a low-level software device for connecting two computers together Sockets can also be used to connect.
Networking with Java CSc 335 Object-Oriented Programming and Design Spring 2009.
Networking java.net package, which provides support for networking. Its creators have called Java “programming for the Internet.” Socket :- A network socket.
CEG3185 Tutorial 4 Prepared by Zhenxia Zhang Revised by Jiying Zhao (2015w)
Greg Jernegan Brandon Simmons. The Beginning…  The problem Huge demand for internet enabled applications and programs that communicate over a network.
Socket programming 1. getByName import java.net.*; public class GetHostName { public static void main (String args[]) { String host = "
SOCKET PROGRAMMING. Client/Server Communication At a basic level, network-based systems consist of a server, client, and a media for communication as.
NET0183 Networks and Communications Lecture 31 The Socket API 8/25/20091 NET0183 Networks and Communications by Dr Andy Brooks Lecture powerpoints from.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 12 Communicating over.
1 CSCD 330 Network Programming Winter 2015 Some Material in these slides from J.F Kurose and K.W. Ross All material copyright Lecture 6 Application.
School of Engineering and Computer Science Victoria University of Wellington Copyright: Peter Andreae david streader, VUW Echo Networking COMP
Socket Programming in Java CS587x Lecture 4 Department of Computer Science Iowa State University.
Practicum: - Client-Server Computing in Java Fundamental Data Structures and Algorithms Margaret Reid-Miller 13 April 2004.
Object Oriented Programming in Java Lecture 16. Networking in Java Concepts Technicalities in java.
Li Tak Sing COMPS311F. Case study: consumers and producers A fixed size buffer which can hold at most certain integers. A number of producers which generate.
Java Sockets Programming
Java Socket programming. Socket programming with TCP.
1 Network Programming and Java Sockets. 2 Network Request Result a client, a server, and network Client Server Client machine Server machine Elements.
L 2 - 1 3( 1/ 20) : Java Network Programming. The Socket API The previous contents describe client-server interaction that application programs use when.
Web Design & Development 1 Lec - 21 Umair Javed. Web Design & Development 2 Socket Programming.
Socket Programming Using JAVA Asma Shakil Semester 1, 2008/2009.
School of Engineering and Computer Science Victoria University of Wellington Copyright: Peter Andreae, VUW Networking COMP # 22.
Networks Sockets and Streams. TCP/IP in action server ports …65535 lower port numbers ( ) are reserved port echo7 time13 ftp20 telnet23.
1 cs205: engineering software university of virginia fall 2006 Network Programming* * Just enough to make you dangerous Bill Cheswick’s map of the Internet.
CS390- Unix Programming Environment CS 390 Unix Programming Environment Java Socket Programming.
By Vivek Dimri. Basic Concepts on Networking IP Address – Protocol – Ports – The Client/Server Paradigm – Sockets The Java Networking Package – The InetAddress.
CSI 3125, Preliminaries, page 1 Networking. CSI 3125, Preliminaries, page 2 Inetaddress Class When establishing a connection across the Internet, addresses.
TCP/IP Protocol Stack IP Device Drivers TCPUDP Application Sockets (Gate to network) TCP: –Establish connection –Maintain connection during the communication.
Prepared by Dr. Jiying Zhao University of Ottawa Canada.
UNIT-6. Basics of Networking TCP/IP Sockets Simple Client Server program Multiple clients Sending file from Server to Client Parallel search server.
Java Programming II Java Network (I) Java Programming II.
Distributed Systems CS Project 1: File Storage and Access Kit (FileStack) Recitation 1, Aug 29, 2013 Dania Abed Rabbou and Mohammad Hammoud.
MT311 Java Application Development and Programming Languages Li Tak Sing ( 李德成 )
Network Programming with Java java.net.InetAddress: public static void main(String[] args) throws UnknownHostException { InetAddress localAddress = InetAddress.getLocalHost();
1 CSCD 330 Network Programming Winter 2016 Some Material in these slides from J.F Kurose and K.W. Ross All material copyright Lecture 6 Application.
Spring/2002 Distributed Software Engineering C:\unocourses\4350\slides\DefiningThreads 1 Java API for distributed computing.
Agenda Socket Programming The OSI reference Model The OSI protocol stack Sockets Ports Java classes for sockets Input stream and.
CSCE 515: Computer Network Programming Chin-Tser Huang University of South Carolina.
Network Programming. These days almost all devices.
Network Programming Communication between processes Many approaches:
Java 13. Networking public class SumTest {
Java.net CS-328 Dick Steflik.
Echo Networking COMP
Network Programming in Java CS 1111 Ryan Layer May 3, 2010
Lecture 21 Sockets 1 (Not in D&D) Date.
Chapter 03 Networking & Security
Network Programming Introduction
NETWORK PROGRAMMING CNET 441
An Introduction to TCP/IP and Sockets
Sockets and URLs 17-Sep-18.
Java Network Programming
CSI 4118 – UNIVERSITY OF OTTAWA
CSCD 330 Network Programming
Sockets and URLs 13-Nov-18.
UNIT-6.
Networking.
Sockets and URLs 3-Dec-18.
CSCD 330 Network Programming
Programming TCP Sockets
Presentation transcript:

PRESENTED To: Sir Abid………. PRESENTED BY: Insharah khan………. SUBJECT: PRESENTED To: Sir Abid……….! PRESENTED BY: Insharah khan………..! SUBJECT: *Programing * PRESENTATION TOPIC: * Network / Socket Programing *

Networking “A computer network is a set of two or more computers connected together in order to share information and other resources.” The computer in a network is connected with one another through cables, satellite or telephone lines. Essential components of every network system are *Hardware *Software *People It is also called information network.

Network topologies: “Physical layout or arrangement of connected devices in a network.”

To send and receive any kind of data or message it is necessary to have IP address of the sender and receiver.

Socket Programming: Sockets provide the communication mechanism between two computers using TCP. A client program creates a socket on its end of the communication and attempts to connect that socket to a server. When the connection is made, the server creates a socket object on its end of the communication. The client and server can now communicate by writing to and reading from the socket. After the connections are established, communication can occur using I/O streams. Each socket has both an OutputStream and an InputStream. The client's OutputStream is connected to the server's InputStream, and the client's InputStream is connected to the server's OutputStream. Two types of TCP sockets 1. The java.net.Socket class represents a socket, It is used by a servers so that they can accept connection. and 2. java.net.ServerSocket class provides a mechanism for the server program to listen for clients and establish connections with them.

ServerSocket Class Methods For Server Socket Class Methods For Client Public Socket(InetAddress host, int port) throws IOException This method except that the host is denoted by an InetAddress object. public Socket(InetAddress host, int port, InetAddress localAddress, int localPort) Except that the host is denoted by an InetAddress object instead of a String public Socket(String host, int port) throws UnknownHostException, IOException. This method attempts to connect to the specified server at the specified port ServerSocket Class Methods For Server public ServerSocket(int port) throws IOException Attempts to create a server socket bound to the specified port. An exception occurs if the port is already bound by another application. public ServerSocket() Creates an unbound server socket. public ServerSocket(int port, int backlog) The backlog parameter specifies how many incoming clients to store in a wait queue.

Connects to a specified host over a specified port and prints out whatever is returned….!

import java. io. ; import java. net. ; import java.io.*; import java.net.*; Request from Client to Server class ConnectDemo { Public static void main (String ars[]) { try { Socket s = new Socket (“10.123.3.34” , 225); DataInputStream inp = new DataInputStream(s.getInputStream () ); Boolean more_data = true; System.out.println(“Established Connection”); while (more_data) { String line = inp.readLine(); if (line==null) more_data = false; else System.out.println(line); } } catch(IOException e) { System.out.print(“IO error” + e) } } }

import java. io. ; import java. net. ; import java.io.*; import java.net.*; Server Response to Client class SimpleServer { public static void main (String args [ ] ) { try { ServerSocket sock = new ServerSocket(7500); Socket newsock = sock.accept ( ); DataInputStream inp = new DataInputStream(newsock . getInputStream ( ) ); PrintStream outp = new PrintStream( ) ; outp.Println(“hello : : enter QUIT to exit” ); Boolean more_data = true; while(more_data) { String line = inp.readLine( ) if (line = = null); more_data = false; else { outp.println ( “ From Server : ” + line + “ln” ) ; if (line. trim() . Equals ( “ QUIT ” ) ) more_data = false ; } } newsock.Close( ) ; }

Catch ( Exception e ) { System.out.print ( “IO error “ + e ) } } }