File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes sockets in basic chat application creating trouble Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "sockets in basic chat application creating trouble" Watch "sockets in basic chat application creating trouble" New topic
Author

sockets in basic chat application creating trouble

trish mo
Greenhorn

Joined: Feb 24, 2011
Posts: 14
I am new to the topic of sockets & testing the waters with a basic chat application (on dos), i intend to work my way upto a full fledged GUI chat application. The code for server & client works fine as long as either one is writing & the other is reading but as soon as my code tries to read from server (on client) & client writes back, the code does nothing & an exception of connection reset is shown.

//Client



//Server



In a previous version of the above code i was using a boolean value to check the condition in an if statement for reading or writing & the value of the flag was reversed in server as well as client i.e., when server was writing client would read & vice versa. But, the error still remained the same.
I think threads are an obvious possibility but there isn't the need of the same in this code since I don't want to handle multiple sessions at this point of time.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38006
    
  22
Using += on a String repeatedly is very inefficient. Use a StringBuilder instead.
 
wood burning stoves
 
subject: sockets in basic chat application creating trouble
 
Similar Threads
How to Change the File Name for Each Uploaded Files to the Socket Server?
Java client socket to talk to C server socket
how to exchange binary data between applet and server socket
Problem from a networking newbie
a total newbie in Sockets