Guest User

Untitled

a guest
Dec 18th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. import java.io.IOException;
  2. import java.io.OutputStream;
  3. import java.io.PrintWriter;
  4. import java.net.InetAddress;
  5. import java.net.Socket;
  6.  
  7. public class Client {
  8.  
  9. public static void main(String[] args) {
  10. // TODO Auto-generated method stub
  11. String str;
  12. str = "Bonjour serveur!!!";
  13. try {
  14. Socket socket = new Socket(InetAddress.getLocalHost(), 1000);
  15.  
  16. OutputStream out = socket.getOutputStream();
  17. PrintWriter ostream = new PrintWriter(out);
  18. ostream.println(str);
  19. ostream.flush();
  20.  
  21. socket.close();
  22. } catch (IOException e) {
  23. // TODO Auto-generated catch block
  24. e.printStackTrace();
  25. }
  26.  
  27. }
  28.  
  29. }
Add Comment
Please, Sign In to add comment