Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Program wont send data through socket.  RSS feed

 
Michael M. Martin
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello my name is Michael. I'm doing a java project involving sockets and multithreading. The problem is that when i click the the button to send data through the sockets to the server. It doesnt invoke the first time but sometimes after pressing it the second time it sends the data. I have tried to locate the cause of this error but it is driving me nuts. I would greatly appreciate some help

This is the code that is executed when i click the button


http://rapidshare.com/files/309260449/JavaProj.rar.html

I have attached the eclipse projects for complete listing of the code at the rapidshare address above. The folder called JavaProj should be placed in yur Cdrive as this is the path i have fixed for the location of the db.

Thanks
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The main problem, I think, is that you have too much code. (If it's too big to post here, it's too big to ask strangers to debug for you.)

For example, there's a whole lot of code in your post which doesn't have anything to do with sending data through sockets. Take all of that code and delete it. In fact, frankly, I could be wrong but I don't see anything there which sends data through a socket, so perhaps you're looking at the wrong code.

Anyway once you get through deleting all the code which is irrelevant to the problem, you should end up with fewer than 50 lines of executable code. It's also possible that once you have done that then the problem won't exist any more. If that's the case then put back the deleted code one piece at a time until the problem starts to happen again, at which time you know the code you just added is causing the problem.
 
Michael M. Martin
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your quick reply. I have this piece of code in a class that builds the server GUI and listens to the server socket. Whenever the user clicks on a button the client is supposed to send the server the command along with the parameters. I have used system.out.println to trace the execution of the code and found out that if i click readfile for example it goes into the button handler down to where it sends the file out through the Printwriter but the server never acknowledges receipt of the command untill i press the button a second time. The same thing happens for write file it goes through the motion but does not write the file untill i click it a second time. is it possible for something to be in the printwriter and because of that it doesn't send out the commands?

here is the full code for the client Gui and socket listener




Here is the thread that managers the request from the cleint (the server)
The server is opened up on port 7777 and uses this thread to handle each client connection

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65826
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Michael Martin----", please check your private messages for an important administrative matter.
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So you have established that the problem is with the sending and/or receiving data through the socket. Given that, then all of your GUI code is irrelevant to the problem. Like I said before, delete all of the irrelevant code. I don't want to look at 500 lines of code when it's already known that the vast majority of it is not relevant to the problem.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!