• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Socket chat problem

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
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);
pw.println(information);

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

}
fluxin = socket.getInputStream ();
OutputStream fluxOut = socket.getOutputStream();
pw = new PrintWriter(fluxOut, true);
pw.println("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 = fluxIn.read(buffer)) != -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.
Pierre
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic