Witam pisze wyszukiwarkę client - server. Wszystko jest ok, wysyłam plik z danymi z klienta do severa tam szukam trafień ale nie mogę odesłać do klienta wyników, ponieważ socket po wysłaniu pliku jest zamknięty i nie mogę drugi raz go otworzyć. Pierwszy raz biorę się za programowanie client-server więc proszę o wyrozumiałość.

SERVER:

package wyszukiwarka_serwer;

import java.net.*;
import java.io.*;
import java.security.GeneralSecurityException;
import java.security.cert.CertificateException;
import java.util.logging.Level;
import java.util.logging.Logger;



public class Server_dane_klawa
{
static String countryfull;
static String country;
static String city;
static String organisation;
static String orgSection;
static String name;
static String mail;
static String attribute;
static String ip_clienta;
static String[] RANK = new String[1024];




    @SuppressWarnings("static-access")
public static void Server() throws CertificateException, GeneralSecurityException, IOException
{
        

BufferedInputStream bis = null;
BufferedOutputStream bos = null;
byte[] data;
Socket socket = null;
ServerSocket serverSocket = null;
int in = 0;
BufferedReader inm = null;
PrintWriter outm = null;
Socket clientSocket;
byte[] byteArray;

 String temp = Wyszukiwarka_serwerView.portas;
 int port = Integer.parseInt(temp);

try //odbieranie danych zebranych przez clienta
{
serverSocket = new ServerSocket(port);
System.out.println("i am server & listening...");
socket = serverSocket.accept();
System.out.println("a client connect");
System.out.println("------1--------" +socket.isClosed());
inm = new BufferedReader(new InputStreamReader(socket.getInputStream()));
outm = new PrintWriter(socket.getOutputStream(), true);

System.out.println("from client: " +inm.readLine());
outm.println("ack 1: hi....");
ip_clienta = inm.readLine();
System.out.println("from client: " +ip_clienta);


try //odbieranie pliku paczka_send.txt
{
byte[] receivedData = new byte[2048];
FileOutputStream fos = new FileOutputStream("e:/odebrana_paczka_send.txt");
bis = new BufferedInputStream(socket.getInputStream());
bos = new BufferedOutputStream(fos);
while ((in = bis.read(receivedData)) != -1)
{
bos.write(receivedData,0,in);
}
bis.close();
bos.flush();
bos.close();
fos.close();
}
catch (IOException e){e.printStackTrace();}


//przypisywanie hashy z pliku odebrana_paczka_send.txt do odp zmiennych

      FileReader ffile = new FileReader("e:/odebrana_paczka_send.txt");
      BufferedReader bread = new BufferedReader(ffile);
      String uu = null;
      int u = 0;
      String[] tablica = new String[1024];

		while((uu = bread.readLine()) != null)
			{
                            u++;
                            uu = bread.readLine();
                            tablica[u] = uu;
			}//tu mam atrybuty w tablicy
                            countryfull = tablica[1];
                            country = tablica[2];
                            city = tablica[3];
                            organisation = tablica[4];
                            orgSection = tablica[5];
                            name = tablica[6];
                            mail = tablica[7];
                            attribute = tablica[8];
                        //tu sa juz przypisane do zmiennych
                bread.close();
		ffile.close();

                Wyszukiwarka_serwerView.console_output.setText(countryfull+" "+country+" "+city+" "+organisation+" "+orgSection+" "+name+" "+mail+" "+attribute);

    }

}

CLIENT:

package wyszukiwarka;

import java.net.*;
import java.io.*;
import java.security.NoSuchAlgorithmException;
import java.util.logging.Level;
import java.util.logging.Logger;


public class Client_send
{

    @SuppressWarnings("static-access")
public static void Client_send() throws IOException
{
Socket clientSocket;
BufferedReader inm = null;
PrintWriter outm = null;
BufferedInputStream bis;
BufferedOutputStream bos;
byte[] byteArray;
int in;

        String countryfull = null;
        String country = null;
        String city = null;
        String organisation = null;
        String orgSection = null;
        String name = null;
        String mail = null;
        String attribute = null;

        String hash_atr = null;
        String hash_mail = null;
        String hash_name = null;
        String hash_orgSection = null;
        String hash_organisation = null;
        String hash_city = null;
        String hash_country = null;
        String hash_countryfull = null;


{ //zczytanie danych z klawy

countryfull = WyszukiwarkaView.Cfull;
country = WyszukiwarkaView.C;
city = WyszukiwarkaView.L;
organisation = WyszukiwarkaView.orga;
orgSection = WyszukiwarkaView.orgSe;
name = WyszukiwarkaView.N;
mail = WyszukiwarkaView.M;
attribute = WyszukiwarkaView.att;

countryfull = countryfull.toUpperCase();
country = country.toUpperCase();
city = city.toUpperCase();
organisation = organisation.toUpperCase();
orgSection = orgSection.toUpperCase();
name = name.toUpperCase();
mail = mail.toUpperCase();
attribute = attribute.toUpperCase();

}

{//hashowanie md5 atrybutow podanego z klawy
    try {
          hash_atr = hashowanie_MD5.MD5(attribute);
          hash_mail = hashowanie_MD5.MD5(mail);
          hash_name = hashowanie_MD5.MD5(name);
          hash_orgSection = hashowanie_MD5.MD5(orgSection);
          hash_organisation = hashowanie_MD5.MD5(organisation);
          hash_city = hashowanie_MD5.MD5(city);
          hash_country = hashowanie_MD5.MD5(country);
          hash_countryfull = hashowanie_MD5.MD5(countryfull);
        }

        catch (NoSuchAlgorithmException ex) {Logger.getLogger(program.class.getName()).log(Level.SEVERE, null, ex);}
        catch (UnsupportedEncodingException ex) {Logger.getLogger(program.class.getName()).log(Level.SEVERE, null, ex);}
}


//zapisanie danych do wysyłu w pliku paczka_send.txt
            BufferedWriter skad = new BufferedWriter(new FileWriter("e:/paczka_send.txt"));
             {
                 skad.newLine();
                 skad.write(hash_countryfull);
                 skad.newLine();
                 skad.newLine();
                 skad.write(hash_country);
                 skad.newLine();
                 skad.newLine();
                 skad.write(hash_city);
                 skad.newLine();
                 skad.newLine();
                 skad.write(hash_organisation);
                 skad.newLine();
                 skad.newLine();
                 skad.write(hash_orgSection);
                 skad.newLine();
                 skad.newLine();
                 skad.write(hash_name);
                 skad.newLine();
                 skad.newLine();
                 skad.write(hash_mail);
                 skad.newLine();
                 skad.newLine();
                 skad.write(hash_atr);
             }
            skad.close();

//CLIENT

 String temp = WyszukiwarkaView.portas;
 int port = Integer.parseInt(temp);

    try
    {
    clientSocket = new Socket(WyszukiwarkaView.IP, port); //lacze   
    System.out.println("i am client & connect");

    InputStream zak_in = clientSocket.getInputStream(); //rozmowa
    OutputStream zak_out = clientSocket.getOutputStream();
    inm = new BufferedReader(new InputStreamReader(zak_in));
    outm = new PrintWriter(zak_out, true);
    System.out.println("------1--------" +clientSocket.isClosed());
    outm.println("msg 1: hi");
    System.out.println("from server__ " +inm.readLine());
    outm.println(WyszukiwarkaView.moje_ip);


    try //wysylanie paczka_send.txt
    {
    bis = new BufferedInputStream(new FileInputStream("e:/paczka_send.txt"));
    bos = new BufferedOutputStream(clientSocket.getOutputStream());
    byteArray = new byte[1024];
    while ((in = bis.read(byteArray)) != -1)
    {
    bos.write(byteArray,0,in);
    }
    bis.close();
    bos.flush();
    bos.close();
    }

    catch(IOException e){e.printStackTrace();}

    System.out.println("-------2-------" +clientSocket.isClosed());
    }
    catch(IOException e){e.printStackTrace();}
}
}

Jak mam napisać odsyłanie pliku z wynikami trafień z servera do klienta?? Z góry dzięki za pomoc.

Pozdrawiam