72 lines
2.1 KiB
Java
72 lines
2.1 KiB
Java
/*
|
|
* Copyright (C) 2021 berdan
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
package test;
|
|
|
|
import java.io.*;
|
|
import java.net.*;
|
|
import utils.Message;
|
|
|
|
/**
|
|
* @author berdan
|
|
*/
|
|
|
|
/*
|
|
Dies ist eine Test-Klasse
|
|
*/
|
|
|
|
|
|
|
|
public class MainClient {
|
|
|
|
public MainClient() throws IOException, ClassNotFoundException {
|
|
System.out.println("[CLIENT] START");
|
|
Socket socket = new Socket( "localhost", 1236 );
|
|
System.out.println("[CLIENT] Debug1");
|
|
ObjectOutputStream oboust = new ObjectOutputStream(socket.getOutputStream());
|
|
System.out.println("[CLIENT] Debug2");
|
|
ObjectInputStream obinstr = new ObjectInputStream(socket.getInputStream());
|
|
System.out.println("[CLIENT] START1");
|
|
Message senden = new Message( "berdan", "test" );
|
|
System.out.println(senden); //nickname=berdan, message=test
|
|
|
|
// Message senden
|
|
oboust.writeObject(senden);
|
|
oboust.flush();
|
|
System.out.println("[CLIENT] NACHRICHT GESENDET");
|
|
|
|
// Message erhalten
|
|
|
|
Object erhalten = null;
|
|
|
|
while(erhalten==null){
|
|
erhalten = obinstr.readObject();
|
|
System.out.println(erhalten);
|
|
}
|
|
System.out.println("[CLIENT] NACHRICHT ERHALTEN");
|
|
System.out.println(erhalten); //nickname=berdan, message=test
|
|
|
|
oboust.close();
|
|
obinstr.close();
|
|
socket.close();
|
|
}
|
|
|
|
public static void main(String args[]) throws IOException, ClassNotFoundException {
|
|
new MainClient();
|
|
}
|
|
}
|