Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Socket chat problem  RSS feed

Pierre Dubeau
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I develop a java application to transfer local file to a server (upload).
Here`s the steps that I followed (pseudo-code):
client side
I send the login information (information)

socket = new Socket ("server", port);
fluxOut = socket.getOutputStream();
pw = new PrintWriter(flux, true);

the server reads the login
and return true or false to the client
ServerSocket server = new ServerSocket (port);
socket = server.accept();

fluxin = socket.getInputStream ();
OutputStream fluxOut = socket.getOutputStream();
pw = new PrintWriter(fluxOut, true);

the client receive from the server (true or false)
InputStream fluxIn = socket.getInputStream ();
BufferedReader br = new BufferedReader(new InputStreamReader(fluxIn));
if the login is valid the client send the file to the server
I open a new socket
socket1 = new Socket("server", port);
fluxOut = socket1.getOutputStream();
InputStream fluxIn = new FileInputStream(file);
the server receive the file
fluxIn = socket.getInputStream()
while ( ( cnt = != -1)
adler32.update(buffer, 0, cnt);
fluxOut.write(buffer, 0, cnt);
When I tried to open an socketOutputStream on the server
and an SocketInputStream on the client, nothing happends!!
when I use System.out.println(socket.toSting() ) it'ok
I got no error such as Socket closed.
Is there a limit of opening new streams to the same socket?

Any clue!!
Thanks for any help.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!