Mam do napisania serwer echo oraz klienta do niego, i wszystko by było ok bo mi sie to udalo ale jest jedno małe ale musi chodzic na poslkich znakach, czyli robić kodowanie cp852 noi nie mam juz do tego sił pomóżcie mi :| wklejam kod serwera oraz klienta:
--------------Serwer::----------------------
import java.net.*;
import java.io.*;
public class ServerEcho {
public static void main (String args[]){
ServerSocket serverSocket = null;
Socket socket = null;
InputStream inp = null;
BufferedReader brinp = null;
DataOutputStream out = null;
System.out.println("Serwer wlaczony");
System.setProperty("file.encoding","Cp852");
try {
serverSocket = new ServerSocket(23);
}
catch(IOException e) {
System.out.println("Blad przy tworzeniu niazda serwerowego.");
System.exit(-1);
}
while(true)
{
try {
System.out.println("Czekam na klienta");
socket = serverSocket.accept();
System.out.println("Polaczony klient "+socket.getInetAddress());
}
catch(IOException e) {
System.out.println(e);
}
try {
inp = socket.getInputStream();
brinp = new BufferedReader(new InputStreamReader(inp,"Cp852"));
out = new DataOutputStream(socket.getOutputStream());
}
catch(IOException e) {
System.out.println("Blad przy tworzeniu strumieni.");
System.exit(-1);
}
String line;
while(true) {
try {
line = brinp.readLine();
if(line.equals("quit")) {
System.out.println("Użytkownik poszedł sobie !!!");
break;
}
System.out.println(line);
out.writeBytes(line + "\n\r");
}
catch(IOException e) {
System.out.println("Blad wejscia-wyjscia.");
System.exit(-1);
}
}
}
}
}
---------------KLIENT--------------
import java.io.* ;
import java.net.* ;
public class EchoClient
{
public static final int PORT = 23 ;
public static final String HOST = "localhost" ;
protected static PrintWriter stdwy=null;
public static void main (String[] args)
{
System.err.println("- uruchomiono klienta ECHO -") ;
System.setProperty("file.encoding","Cp852");
//System.out.println("łóżko");
try
{
BufferedReader stdwe = new BufferedReader(new InputStreamReader(System.in,"Cp852")) ;
try{
stdwy = new PrintWriter(new OutputStreamWriter(System.out,"Cp852"), true) ;
}
catch(Exception e){
System.out.println("Nie można ustawić strony kodowej Cp852.");
stdwy = new PrintWriter(new OutputStreamWriter(System.out), true);
}
Socket gniazdo = new Socket(HOST,PORT) ;
System.err.println("-- otworzono polaczenie (local port: "+
gniazdo.getLocalPort()+" // remote host: "+
gniazdo.getInetAddress().getHostName()+" : "+
gniazdo.getPort()+") --") ;
BufferedReader we = null ;
PrintWriter wy = null ;
try
{
we = new BufferedReader(new InputStreamReader(gniazdo.getInputStream(),"Cp852")) ;
wy = new PrintWriter(gniazdo.getOutputStream(),true) ;
while (true)
{
String linia = stdwe.readLine() ;
wy.println(linia) ; //tym wysyła linie do serwera
if (linia.equals("quit")) break ;
stdwy.println(we.readLine()) ; //a tym chyba odbiera
//System.out.println(stdwy);
System.out.println(we.readLine());
}
}
catch (IOException ex) {}
finally
{
if (we!=null) try { we.close() ; } catch (IOException ex) {}
if (wy!=null) wy.close() ;
}
gniazdo.close() ;
System.err.println("-- zamknieto polaczenie --") ;
}
catch (UnknownHostException ex) { System.err.println("- nieznany host -") ; }
catch (IOException ex) { System.err.println("- blad we/wy -") ; }
System.err.println("- zatrzymano klienta ECHO -") ;
}
}
błagam o pomoc !!!