Using Sockets in Java - PowerPoint PPT Presentation

About This Presentation
Title:

Using Sockets in Java

Description:

Davide Rossi 2002. 4. IP and Internet Addresses ... Davide Rossi 2002. 11. Connecting to a Remote Host. Socket s = new Socket('my.host.it', 1234) ... – PowerPoint PPT presentation

Number of Views:57
Avg rating:3.0/5.0
Slides: 12
Provided by: davide54
Category:
Tags: java | rossi | sockets | using

less

Transcript and Presenter's Notes

Title: Using Sockets in Java


1
Using Sockets in Java
2
TCP/IP
  • A protocol is a set of rules that determine how
    things communicate with each other
  • The software which manages Internet communication
    follows a suite of protocols called TCP/IP
  • The Internet Protocol (IP) determines the format
    of the information as it is transferred
  • The Transmission Control Protocol (TCP) dictates
    how messages are reassembled and handles lost
    information

3
IP
  • Internet Protocol RFC 791
  • Base protocol for data transmission
  • It is connectionless and unreliable
  • It is routable
  • Defines the addressing of the nodes using IP
    addresses

4
IP and Internet Addresses
  • Each computer on the Internet has a unique IP
    address, such as
  • 130.136.1.110
  • Most computers also have a unique Internet name,
    which also is referred to as an Internet address
  • www.cs.unibo.it
  • The first part indicates a particular computer
    (www)
  • The rest is the domain name, indicating the
    organization (cs.unibo.it)

5
TCP
  • Transmission Control Protocol RFC 793
  • Its a reliable connection-oriented protocol
  • Reliability is achieved using packets indexing
    and generating ack messages for each received
    packet

6
TCP
  • Creating a connection is an asymmetrical process
    once the connection is established the protocol
    becomes symmetric
  • Ports are used to initiate a connection

7
Connection Sequence
Server
Client
my.server.it
FTP
HTTP
Web Browser
POP
http//my.server.it
23
110
80
8
TCP Standard Ports
  • Below 1024, assigned by the IANA

21 FTP
23 Telnet
80 HTTP
110 POP3
119 NNTP
9
TCP Connections in Java
  • The Socket class is used for handling TCP
    connections in Java
  • A socket can be used as a data source for a
    stream
  • The SocketServer class is used to establish a
    connection

10
Waiting for a Connection
  • ServerSocket ss new ServerSocket(1234)
  • Socket s ss.accept()

11
Connecting to a Remote Host
  • Socket s new Socket(my.host.it, 1234)
Write a Comment
User Comments (0)
About PowerShow.com