File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Sockets and Internet Protocols and the fly likes Socket  chat problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Socket  chat problem" Watch "Socket  chat problem" New topic
Author

Socket chat problem

Pierre Dubeau
Greenhorn

Joined: Feb 19, 2001
Posts: 7
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Socket chat problem
 
Similar Threads
how can i send a file(urgent)
i am in trouble
urgent
How can I specify size of a String?
How to send a message back from Server to Client?