Sockets and URLs 13-Nov-18.

Slides:



Advertisements
Similar presentations
Networking with Java 1. Introduction to Networking 2.
Advertisements

Programming TCP Clients Version InetAddress Class An IP address identifies uniquely a host in the internet, which consists of 4 numbers (1 byte.
Prepared By E. Musa Alyaman1 URLs, InetAddresses, and URLConnections Chapter 9.
Basic Socket Programming with Java. What is a socket?  Generally refers to a stream connecting processes running in different address spaces (across.
Socket Programming.
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.
Programming TCP Clients. InetAddress Class An IP address identifies uniquely a host in the internet, which consists of 4 numbers (1 byte each one) in.
Networking Support In Java 2 Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Internet Programming In Java. References Java.sun.com Java552 Many of the programs shown.
COMP1681 / SE15 Introduction to Programming
CIS – Spring Instructors: Geoffrey Fox, Bryan Carpenter Computational Science and.
Client/Server In Java An Introduction to TCP/IP and Sockets.
Networking Support In Java Nelson Padua-Perez Bill Pugh Department of Computer Science University of Maryland, College Park.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 25 Networking.
Programming TCP Clients Version InetAddress Class An IP address identifies uniquely a host in the internet, which consists of 4 numbers (1 byte.
Networking Support In Java 2 Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
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 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)
Socket programming 1. getByName import java.net.*; public class GetHostName { public static void main (String args[]) { String host = "
Appendix F: Network Programming in Java ©SoftMoore ConsultingSlide 1.
Application Protocols: HTTP CSNB534 Semester 2, 2007/2008 Asma Shakil.
DBI Representation and Management of Data on the Internet.
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
L 2 - 1 3( 1/ 20) : Java Network Programming. The Socket API The previous contents describe client-server interaction that application programs use when.
NETWORK PROGRAMMING.
Socket Programming Using JAVA Asma Shakil Semester 1, 2008/2009.
CS390- Unix Programming Environment CS 390 Unix Programming Environment Java Socket Programming.
Java IO. Why IO ? Without I/O, your program is a closed box. Without I/O, your program is a closed box. I/O gives your Java program access to your hard.
TCP/IP Protocol Stack IP Device Drivers TCPUDP Application Sockets (Gate to network) TCP: –Establish connection –Maintain connection during the communication.
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 ( 李德成 )
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.
Prepared by: Dr. Abdallah Mohamed, AOU-KW Unit9: Internet programming 1.
Java 13. Networking public class SumTest {
Java.net CS-328 Dick Steflik.
Object-Orientated Analysis, Design and Programming
Secure Sockets SSL (Secure Sockets Layer) is a standard security technology for establishing an encrypted link between a server and a client—typically.
Echo Networking COMP
Source: Java Sockets Source:
Network Programming Introduction
MCA – 405 Elective –I (A) Java Programming & Technology
NETWORK PROGRAMMING CNET 441
An Introduction to TCP/IP and Sockets
PRESENTED To: Sir Abid………. PRESENTED BY: Insharah khan………. SUBJECT:
Network Programming Introduction
Network Programming Introduction
Sockets and URLs 17-Sep-18.
Java Network Programming
Clients and Servers 19-Nov-18.
URL in Java C343 Lab (Week 13).
Clients and Servers 1-Dec-18.
Networking.
Sockets and URLs 3-Dec-18.
Networking.
Programming TCP Sockets
Uniform Resource Locator: URL
Programming TCP Clients
Clients and Servers 19-Jul-19.
Clients and Servers 13-Sep-19.
Presentation transcript:

Sockets and URLs 13-Nov-18

Sockets A socket is a low-level software device for connecting two computers together Sockets can also be used to connect two programs running on the same computer There are two kinds of sockets: A Socket is a client socket, and initiates the communication A ServerSocket waits for a request; it then May perform the requested action May return a result to the requester

Socket constructors Socket(InetAddress address, int port) Creates a stream socket and connects it to the specified port number at the specified IP address ServerSocket(int port) Creates a server socket on the specified port, with a default queue length of 50 The actual work, for both kinds of sockets, is done by an instance of the SocketImpl class

Some Socket methods getInputStream() getOutputStream() close() Returns an input stream for this socket getOutputStream() Returns an output stream for this socket close() Closes this socket

Some ServerSocket methods accept() Listens for a connection to be made to this socket and accepts it Returns a Socket as its result For input, use the getInputStream() and getOutputStream() methods on the returned Socket close() Closes this socket

Socket fields protected InetAddress address The IP address of the remote end of this socket protected FileDescriptor fd The file descriptor object for this socket protected int localport The local port number to which this socket is connected protected int port The port number on the remote host to which this socket is connected

URLs A URL is a Uniform Resource Locator, typically a Web address Some constructors: URL(String spec) Creates a URL object from the information in the String URL(String protocol, String host, int port, String file) Creates a URL object from the specified protocol, host, port number, and file URL(String protocol, String host, String file) Same as above, but uses the default port for this protocol

Some URL methods openStream() openConnection() Opens a connection to this URL and returns an InputStream for reading from that connection openConnection() Returns a URLConnection object that represents a connection to the remote object referred to by the URL getProtocol(), getHost(), getPort(), getFile(), getQuery()

Using a URLConnection The steps in using a URLConnection are: Use openConnection() to create the URLConnection object Set the parameters as desired: setAllowUserInteraction, setDoInput, setDoOutput, setIfModifiedSince, setUseCaches, setRequestProperty Use the connect method to make the actual connection Use the remote object

Some URLConnection methods getHeaderField(int n) Returns the value for the nth header field getHeaderField(String name) Returns the value of the named header field getHeaderFieldKey(int n) Returns the key for the nth header field getInputStream() Returns an input stream that reads from this open connection getOutputStream() Returns an output stream that writes to this connection

The End