Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package klient.warcaby.wykonanie;
- import java.io.*;
- import java.net.*;
- public class Klient {
- public static void main(String[] args) {
- Komunikator komunikator = new Komunikator();
- Socket gniazdo = null;
- OutputStream strumienWyjscia = null;
- InputStream strumienWejscia = null;
- PrintWriter wyjscie = null;
- BufferedReader wejscie = null;
- try {
- gniazdo = new Socket("localhost", 7734);
- } catch (UnknownHostException e) {
- System.out.println("Nie znaleziono hosta");
- } catch (IOException e) {
- System.out.println("Nie udało się utworzyć gniazda");
- }
- try {
- strumienWejscia = gniazdo.getInputStream();
- strumienWyjscia = gniazdo.getOutputStream();
- } catch (IOException e) {
- System.out.println("Nie można pobrać strumienia wejściowego");
- }
- wyjscie = new PrintWriter(strumienWyjscia, true);
- wejscie = new BufferedReader(new InputStreamReader(strumienWejscia));
- System.out.println(komunikator.odbierz(wejscie));
- komunikator.wyslij("Klient melduje sie",wyjscie);
- try{
- wyjscie.close();
- wejscie.close();
- strumienWyjscia.close();
- strumienWejscia.close();
- gniazdo.close();
- }catch(IOException e){
- System.out.println("Nie udało się zamknąć strumieni i gniazd");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement