1 / 11

Using Sockets in Java

Using Sockets in Java. 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

Download Presentation

Using Sockets in Java

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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Using Sockets in Java Davide Rossi 2002

  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 Davide Rossi 2002

  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 Davide Rossi 2002

  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) Davide Rossi 2002

  5. TCP • Transmission Control Protocol: RFC 793 • It’s a reliable connection-oriented protocol • Reliability is achieved using packets indexing and generating “ack” messages for each received packet Davide Rossi 2002

  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 Davide Rossi 2002

  7. Connection Sequence Server Client my.server.it FTP HTTP Web Browser POP http://my.server.it 23 110 80 Davide Rossi 2002

  8. TCP Standard Ports • Below 1024, assigned by the IANA Davide Rossi 2002

  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 Davide Rossi 2002

  10. Waiting for a Connection ServerSocket ss =new ServerSocket(1234); Socket s = ss.accept(); Davide Rossi 2002

  11. Connecting to a Remote Host Socket s = new Socket(“my.host.it”, 1234); Davide Rossi 2002

More Related