Advertisement
Guest User

Untitled

a guest
Oct 14th, 2019
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. package com.company;
  2. import java.net.*;
  3. import java.io.*;
  4.  
  5.  
  6. public class Main {
  7.  
  8. public static void main(String[] args) {
  9. Socket socket =null;
  10. Socket socket1 = null;
  11. Socket socket2 = null;
  12. Socket socket3 = null;
  13. try {
  14. socket = new Socket("wp.pl", 80);
  15. socket1 = new Socket("onet.pl", 80);
  16. socket2 = new Socket("ug.gda.pl", 80);
  17. socket3 = new Socket("interia.pl", 80);
  18.  
  19.  
  20. }
  21. catch(UnknownHostException e) {
  22. System.out.println(e);
  23. }
  24. catch(IOException e) {
  25. System.out.println(e);
  26. }
  27. if(socket!=null) {
  28. System.out.println(socket);
  29. }
  30. if(socket1!=null) {
  31. System.out.println(socket1);
  32. }
  33. if(socket2!=null) {
  34. System.out.println(socket2);
  35. }
  36. if(socket3!=null) {
  37. System.out.println(socket3);
  38. }
  39.  
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement