Beruflich Dokumente
Kultur Dokumente
Objectives
Internet and Internet Protocol (IP) Introduction to TCP packets To understand the concept of sockets
Data Transmission
Consists of sending/receiving streams of zeros and ones along the network connection Two Types of Information
Application data The information one computer wants to send to another Protocol data Describes how to reach the intended computer Describes how to check for errors in the transmission
IP Packets
IP breaks large chunks of data up into more manageable packets Each packet is delivered separately Each packet in a larger transmission may be sent by a different route Packets are numbered
TCP's Job
Attempt to deliver the data Try again if there are failures Notify the sender whether or not the attempt was successful
Port Numbers
One computer can offer multiple services over the Internet
For example, both a web server program and an email server program could reside at the same machine
When data are sent to that computer, they need to indicate which program (service) is to receive the data IP uses port numbers for this
A port number is an integer between 0 and 65,535 Some of these are preallocated for certain applications (wellknown ports b/w 1-1023) The sending program must know the port number of the receiving program This number is included in the transmitted data
Continued
Port Numbers
Some well known port numbers include:
HTTP 80 HTTPS 443 FTP 20-21 Telnet 23 SMTP 25 POP3 110 IMAP14
Continued
Syntax in Java
ServerSocket servSock = new ServerSocket(PORT);
An integer b/w 1024-65535 (eg.1234) because port numbers up to 1023 are reserved for special services Continued
Continued
Scanner input = new Scanner(link.getInputStream()); PrintWriter output = new PrintWriter (link.getOutputStream(), true);
Continued
Continued
Continued
Continued
Continued
Continued