java networking n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Java Networking PowerPoint Presentation
Download Presentation
Java Networking

Loading in 2 Seconds...

play fullscreen
1 / 17

Java Networking - PowerPoint PPT Presentation


  • 81 Views
  • Uploaded on

Java Networking. RGEC Meerut. Open System Connection . The OSI model describes the architecture for inter computer Communications. Data moves down the layers of the source computer,across a physical medium, then back up the layers of the destination computer. Networks/Protocols.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Java Networking' - brett-odonnell


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
java networking

Java Networking

RGEC Meerut

RGEC MEERUT(IWT CS703)

open system connection
Open System Connection
  • The OSI model describes the architecture for inter computer Communications.
  • Data moves down the layers of the source computer,across a physical medium, then back up the layers of the destination computer

RGEC MEERUT

networks protocols
Networks/Protocols
  • Computer network
    • A set of computers using common protocols to communicate over connecting transmission media.
  • Protocol
    • A formal description of message formats and the rules two or more machines follow to exchange messages.
    • Transmission Control Protocol/Internet Protocol (TCP/IP) is a very popular protocol in use today.

RGEC MEERUT(IWT CS703)

socket based communication
Socket Based Communication
  • Programs running on separate machines can communicate with each other through designated TCP/IP sockets
  • Sockets are the endpoints of logical connections between two hosts and can be used to send and receive data
  • Socket communication in Java works similarly to I/O Operations

RGEC MEERUT(IWT CS703)

stream sockets
Stream Sockets
  • Stream sockets use TCP (Transmission ControlProtocol) for data transmission .
  • TCP is lossless and reliable because it can detect lost transmissions and resubmit them.
      • All data sent is received in the same order it was sent.
  • A stream of 8-bit bytes is exchanged across a TCP connection.
  • Connections provided by TCP allow concurrent transfer in both directions. Such connections are called full duplex.
  • A fitting analogy is a telephone connection with a dedicated link.
  • With the chat project, all conversations between usersare handled using stream sockets .

RGEC MEERUT(IWT CS703)

connection oriented transfer
Connection –Oriented Transfer

RGEC MEERUT(IWT CS703)

datagram sockets
Datagram Sockets
  • Datagram sockets use UDP (User Datagram Protocol) for data transmission .
  • UDP cannot guarantee that packets are not lost, or not received in duplicate, or received in the order they were sent.
  • An analogy is the sending of letters through the post office
    • Although you don’t get duplicate letters.
  • With the chat project, the broadcasting of the registered user list is handled using datagram sockets.

RGEC MEERUT(IWT CS703)

connectionless transfer
Connectionless Transfer

RGEC MEERUT(IWT CS703)

client server computing
Client/Server Computing

RGEC MEERUT(IWT CS703)

server socket
Server Socket
  • To establish a server, you need to create a server socket and attach it to a port where the server will listen for connections
    • Port numbers range from 0 to 65536
  • Ports 0 to 1024 are reserved for privileged services
  • ftp runs on port 21
  • sendmail runs on port 25
  • http runs on port 80
  • To create a server socket on port 8000:
  • // running on server: rgec.edu
  • try {
  • ServerSocket servSocket = new ServerSocket(8000);
  • } catch (java.net.BindException) {
  • // port is already in use}

RGEC MEERUT(IWT CS703)

client sockets
Client Sockets
  • After a server socket is created, the server can listen for client connections using accept()
  • // running on server: rgec.edu
  • Server socket = servSocket.accept();
  • The statement blocks until a client connects to the server socket using the server host name
  • // running on client: ikaruga.cs.rit.edu
  • Socket socket = new Socket(“rgec.edu”, 8000);
  • alternatively, you can specify the IP address in a string:
  • “129.21.36.165”

RGEC MEERUT(IWT CS703)

client socket
Client Socket
  • If you provide a host name instead of an IP when creating a socket, Java will query a Domain Name Server to do the translation.
  • The hostname localhost refers to the machine on which a client is running

“There’s no place like 127.0.0.1”

RGEC MEERUT(IWT CS703)

data transmission through sockets1
Data Transmission Through Sockets
  • The socket returns an InputStream and OutputStream for reading and writing bytes.
  • InputStream is =socket.getInputStream();
  • OutputStream os = socket.getOutputStream();
  • • For efficiency, wrap those streams to do binary I/O:
  • DataInputStream input = new DataInputStream(is);
  • DataOutputStream output = new DataOutputStream(os);

RGEC MEERUT(IWT CS703)

inetaddress
InetAddress
  • Use InetAddress to find the hostname and IP of a client connecting to a server.
  • InetAddress inetAddress = socket.getInetAddress();
  • System.out.println(“Client’s host name is “ + inetAddress.getHostName());
  • System.out.println(“Client’s IP address is “ +inetAddress.getHostAddress());
  • • You can create an instance of InetAddress using the static method getByName(String).
  • InetAddress address =InetAddress.getByName(“rgec.edu”);

RGEC MEERUT(IWT CS703)

client server example
Client/Server Example
  • Write a client program which sends the radius of a circleto a server program, which computes the area and then sends the result back to the client

RGEC MEERUT(IWT CS703)

slide17
Port

Protocol Port Number

Datatime 13

FTP –data 20

FTP –Control 21

Telnet 23

SMTP 25

HTTP 80

POP3 110

NNTP 119

RGEC MEERUT(IWT CS703)