The Sockets API ◦ What is a Socket? What identifies a socket? ◦ Types of sockets
•
Sockets in Java ◦ TCP Sockets ▪ Socket class. Use of close. ▪ TCP Clients •
Exception handling with try … catch
•
Readin from a socket: getInputStream. Line oriented reading with Scanner class. Methods: next, nextInt, nextLine, hasNext …. ◦ Reading from the keyboard.
•
Writing to a socket: getOuputStream. Text-oriented write : PrintWriter class. ◦ print & println. Warning: platform-depented end-of-line. ▪ Warning: The need of flushing buffers to avoid a deadlock. método flush (flush method on clases OutputStream & PrintWriter).
◦ InetAddress class for Internet Addresses in Java. ▪ How to learn about addresses in use in the current connection: métodos getLocalPort, getPort, getLocalAddress and getInetAddress. ▪ Getting parameters from standard input. Convert an String into an int for port numbers.
Exercises: •
Exercise#1: Write a program that will connect to port 80 at server “www.upv.es”, printing the message “Connected!” after establishing the connection and next closing the connection and ending. (No need to include exception handling code).
•
Exercise#2: Add another method to the program above. This new method will do as #1 but now exception handling is required (using try … catch). Change the connected message to string “Connected again!”. •
Run it and check it works too.
•
Now change port number to 81 and try again. What happens?
•
Restore port number to 80. Change the server name adding an additional “w” to the name. Try again to see what happens.
•
When trying to connect a socket, when do UnknownHostException and IOException happen?
•
Exercise#3: Add a new method to your program that will connect to port 25 on “smtp.upv.es” server, after the connection is made, it will read the first text line from the socket and it will print it to the standard output.
•
Exercise#4: Daytime client. It just connects to port 13 on “ntp.upv.es” server and it prints a single line to stdout.
•
Exercise#5: Basic HTTP/1.0 client. It will connect to port 80 on “www.upv.es” server and it will transmit the text “GET / HTTP/1.0\r\n\r\n”. Next it will wait for any received text over the socket that will be printed to stdout.
•
Excercise#6: Add yet another method to your program. This time it will be a client connecting to port 25 on UPV STMP server (smtp.upv.es). Once the connection is established, the program will show the values of local and remote port and the IP address of the server. Run it three times and notice the changes in the values shown.
•
Exercise#7(optional): Make changes to the program above so it will accept server name and port number as command line arguments.
Sockets (i). Book reading: Kurose 2.7. Other info: ⢠http://download.oracle.com/javase/6/docs/api/index.html. ⢠The Sockets API. ⦠What is a Socket? What identifies a socket? ⦠Types of sockets. ⢠Sockets in Java. ⦠TCP Sockets. ⫠Socket class. Use of close. ⫠TCP Clients. ⢠Exception handling with try ⦠catch. ⢠Readin from a ...
TCP guarantees the delivery of packets and preserves their order on destination. Sometimes these features are not required, since they do not come without performance costs, it would be better to use a lighter transport protocol such as UDP (User Dat
ABET is the engineering accreditation system. It accredits ChE, EE, ... biology background are generally necessary for the BM track, yet ABET does not allow any Bi classes to count toward accreditation. Therefore, despite that Bi/Ch110 is a requireme
raid the arsenal, kill all the white residents, free the. slaves, and burn the city to the ground. Like Gabriel Prosser, Vesey was betrayed by. some of his followers.
Loading⦠Page 1. Whoops! There was a problem loading more pages. Retrying... Sumer Camp Turo 2015 Info i reserva.pdf. Sumer Camp Turo 2015 Info i reserva.pdf. Open. Extract. Open with. Sign In. Main menu. Displaying Sumer Camp Turo 2015 Info i rese
Retrying... Whoops! There was a problem previewing this document. Retrying. ... Parent Portal Info Access Info and Mobile App for Schools.pdf. Parent Portal Info ...
Marching Band Shoes: Size ______ $30 ______. Total: ______. Please make checks out to Wauconda HS. All marching band shoes, lyres, and flip. folders purchased with this order will be given to the students on the first day of. marching band camp Augus
Sign in. Loading⦠Page 1. Whoops! There was a problem loading more pages. Retrying... Provisional info. Provisional info. Open. Extract. Open with. Sign In.
In all participating countries, xenophobia and discrimination form a big problem. Especially. economic crisis contributes to this situation, when foreigners are ...
NOTE : Full 2 marks to be allotted if reason explained with the help of. any correct example. (b) Compare BUS topology with STAR topology. Give example. 2. Ans. BUS topology STAR topology. In Bus topology all the nodes are. joined to one cable (the b
Loading⦠Whoops! There was a problem loading more pages. Whoops! There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. Main menu. There was a problem previewing
Mar 19, 2018 - Baltic Sea Labour Forum (7 min). ⢠Baltic Science Network (7 min) b. Emerging flagship;. ⢠BSR SMART LIFE (7 min). 4. Thematic discussions in five groups. Participants can choose two groups (90 min (45 min in each group)). ⢠Comb