Bookmark Topic Watch Topic
  • New Topic

server to client problem

 
Doua Beri
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi everyone. I have created a client/server system. Let's say there is such a situation:


so there must be a situation on the server side I send 100 messages to a client one after another(this is just to test the limits of my program) and on the client side I don't receive all the messages. some of them are being lost.
but if I do something like this



it's working great, but the messages are being send very slow.
So the problem is how can I do so I can send 100 messages to client the fastest way possible.

Thank you
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Report post to moderator
What kind of communication channel is this? Are both sides under your control, so that you can instrument it for debugging?
 
Doua Beri
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Report post to moderator
Ulf Dittmer wrote:What kind of communication channel is this? Are both sides under your control, so that you can instrument it for debugging?


hi. thanks for your reply. Yes I can change the source code on both client and server if that's what you mean.
On the server side every client has it's own thread but, I need to find a method to send a lot of message from the server to a certain client in the fastest way as possible. The first method that I presented to you in the first post send the packets very fast but, I don't receive all the packets. ( i should receive the numbers from 0 to 99 but sometimes it skips a number ). The second method send all the messages but is very slow.

I send the messages to the client with PrintStream . I'm using the old socket api, I never tested the new nio api since I have to change a lot in my program.

The sever is designed in java, but the client is not so i'm a little limited on the client side.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Report post to moderator
OK, so you're using Java sockets; that's fine.

Are both sides using the same OS and encoding? Make sure you're not inadvertently use println with a Socket, and that there are no encoding issues with PrintStream.

I'd start by investigating where the messages are getting lost (client, server, in between); a tool like Wireshark that shows what goes over the wire can help with that.

You might also want to add some control features to your protocol, so that the receiving end signals successful transmission to the sender.
 
Doua Beri
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Report post to moderator
Ulf Dittmer wrote:OK, so you're using Java sockets; that's fine.

Are both sides using the same OS and encoding? Make sure you're not inadvertently use println with a Socket, and that there are no encoding issues with PrintStream.

I'd start by investigating where the messages are getting lost (client, server, in between); a tool like Wireshark that shows what goes over the wire can help with that.

You might also want to add some control features to your protocol, so that the receiving end signals successful transmission to the sender.




the client doesn't receive the message, so the lost is somewhere between the server and the client. the server is running on linux and the client on windows.
To send a message I use the following code:



I think the problem is that I send one message and after that I send another one without having any confirmation that the client received the first message.
Do you think a send message- receive confirmation implementation is required, cause this may cause a lot of problems( I think), but if you think that's a good idea can you direct me to some good example.



 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Report post to moderator
the client doesn't receive the message, so the lost is somewhere between the server and the client.

Or it isn't actually sent. Make sure it does go out over the wire like I suggested. TCP is a reliable protocol - no packets should ever get lost in the ether without TCP at least notifying you about it.

the server is running on linux and the client on windows.

In that case you do need to pay attention to encodings and line endings. These are probably not the cause of your problem, though.

Do you think a send message- receive confirmation implementation is required, cause this may cause a lot of problems

Right now -without such a confirmation- you do have problems as well, don't you? And it's possible that while implementing an acknowledgment scheme you find the cause of the original problem.
 
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!