Re: Server-client ping system won't work. (message being sent but not received)

Please post the code on the forum.

June 3rd, 2012, 01:40 PM

d4dev

Re: Server-client ping system won't work. (message being sent but not received)

Did that, all other code is still visible in the github.

June 3rd, 2012, 01:48 PM

Norm

Re: Server-client ping system won't work. (message being sent but not received)

The posted code does not compile because of missing classes.

Try making a small program that compiles, executes and shows the problem.

June 3rd, 2012, 03:06 PM

d4dev

Re: Server-client ping system won't work. (message being sent but not received)

Why whould you need to compile it? I really do think it's something little I've looked over since it almost always is... And it doesn't give an error or so, it just never says anything in the server while it does say "ping..."in the client once per second.

June 3rd, 2012, 03:09 PM

Norm

Re: Server-client ping system won't work. (message being sent but not received)

I let the computer tell me what is wrong. Too easy to misread code.
Also you cant always tell if something important is missing. Having all the code keeps that from happening.
If only the posted code is needed to find the problem, can you modify it and add to ti so that it compiles, executes and shows the problem?

June 3rd, 2012, 03:10 PM

d4dev

Re: Server-client ping system won't work. (message being sent but not received)

Ok, but I have to go in a hurry now, forgot the time. Ill make a compiling version later.

June 4th, 2012, 12:26 AM

d4dev

Re: Server-client ping system won't work. (message being sent but not received)

Okay, I made it so it can compile.
server
clientaccepter.java, accepts incoming connections

Re: Server-client ping system won't work. (message being sent but not received)

Try debugging the code by adding lots of println statements to show where the code is executing and to show the values of all the variables as their values change. The print out will show you where the problem is.

June 4th, 2012, 08:53 AM

d4dev

Re: Server-client ping system won't work. (message being sent but not received)

The problem is, I already did that and it did say ping... in the client, and in the server the while loop was running... I'll try it again.

June 4th, 2012, 08:56 AM

Norm

Re: Server-client ping system won't work. (message being sent but not received)

Did you add enough printlns to show what the code is doing and how the values of variables change?

June 4th, 2012, 08:57 AM

d4dev

Re: Server-client ping system won't work. (message being sent but not received)

Probably not...

June 4th, 2012, 09:00 AM

d4dev

Re: Server-client ping system won't work. (message being sent but not received)

Why?
Shouldn't in.read give -1 when it reaches the end?
Edit:
Ow wait, it keeps reading one, probably some in.next() or so I forgot... Searching...

Edit 2:
I found it. Most stupid mistake ever. However, I did expect something like this to be the problem. Thanks

June 4th, 2012, 09:06 AM

Norm

Re: Server-client ping system won't work. (message being sent but not received)

What is the value of chr? Cast it to char when you print it.

July 2nd, 2012, 12:40 PM

Voodoo

Re: Server-client ping system won't work. (message being sent but not received)

d4dev
I see you have 3 diff. threads. 1 server (ClientAccepter), 1 Connection and 1 Client...
I see how the server accepts an incomming request and starts the Client thread...
But I don't know where the Connection is invoked...
Your server can receive an incoming request only if this Connection thread is started somewhere...then your Client thread is started...when your client is started IT PINGS !

July 2nd, 2012, 12:45 PM

Voodoo

Re: Server-client ping system won't work. (message being sent but not received)

d4dev
I review your codes and don't find the relationship between the thread Connection and the Client+ClientAccepter thread. May I give you a hint? Don't use excessive threads. They can cause lots of hidden problems (e.g. Synchronization)