Note that there are some explanatory texts on larger screens.

plurals
  1. POSOCKET Handling Concurrent server and client comunication
    primarykey
    data
    text
    <p>I'm experiencing some problems with sockets. </p> <p>I'm trying to make a concurrent server to accept more than one clients. </p> <p>When a client connects to the server, the server creates a new thread and listens to the socket. Then, if the client sends something, the server must read it. </p> <p>On the client i just open a dictionary (txt form) and i send it over the socket. </p> <p>On the server the only thing i get is this:</p> # <p>null</p> <p>SERVER</p> <pre><code> try { String message,file = new String("StressTextFile.txt"); File filee = new File(file); long length; // Open the file FileInputStream fstream = new FileInputStream(file); // Get the object of DataInputStream DataInputStream in = new DataInputStream(fstream); BufferedReader br = new BufferedReader(new InputStreamReader(in)); String strLine = new String(); length = filee.length(); ProgressBar.setMaximum((int)length); //we're going to get this many bytes ProgressBar.setValue(0); //we've gotten 0 bytes so far //Read File Line By Line font1 = new Font("Helvetica", Font.PLAIN, 18); font1.isBold(); color = new Color( 74,118,110); TextArea1.setForeground(color); TextArea1.setFont(font1); int soma=0; while(in.readLine() != null) { strLine = in.readLine(); // reads from file //System.out.println(strLine); TextArea1.append(strLine+"\n"); pwOut.write(strLine); pwOut.flush(); soma+=strLine.length()+1; ProgressBar.setValue(ProgressBar.getValue()+(strLine.length()+1)*2); ProgressBar.repaint(); }; br.close(); pwOut.close(); Skt.close(); }catch (Exception e){ System.err.println("Error: " + e.getMessage()); } } </code></pre> <p>CLIENT </p> <pre><code> try { brIn = new BufferedReader(new InputStreamReader(skt.getInputStream())); while(s != null) { s = brIn.readLine(); System.out.println("#####"); System.out.println(s); } } catch (IOException e1) {e1.printStackTrace(); } </code></pre> <p>Please forget the Swing components. I think all socket stuff are ok. why can't i get nothing on the server side?</p> <p>Please help</p> <p>Kind regards</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload