-
Connection reset problem
I have coded a server-client chat, as many others, but I have a little problem. The chat works perfectly and you can chat all you want, but now its on a rather big server and after the chat server has been online for a while you can't join the chat anymore. I write the error message in a file and it says "Connection reset".
Here goes the code of the ServerSocket listener thread(where the error should be), if you got any tips please share them with me. (and getMess is a thread class and not a method, bad choice of name by me)
class Connect extends Thread
{
private int port;
private ChatServer cs;
private LinkedList playerList;
private ServerSocket listenSock;
public Connect(LinkedList l) throws IOException
{
super("GH Chat Server");
playerList = l;
port = 8072;
cs = new ChatServer(playerList);
this.start();
}
public void run()
{
try
{
ServerSocket listenSock = new ServerSocket(port);
while(!interrupted())
{
Socket clientSock = listenSock.accept();
new getMess(clientSock, cs, playerList);
}
}
catch(Exception e)
{
try
{
File f1 = new File("error_logs");
f1.mkdir();
File path = new File("error_logs\\error.rtf");
RandomAccessFile fil = new RandomAccessFile(path, "rw");
fil.seek(fil.length());
fil.writeBytes(e.getMessage() + '\n' + "End of transmission!!" + '\n');
fil.close();
}
catch(Exception ie){}
}
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks