Client / Server question

Greertings

I have a delphi client (TIdTCPClient), that sends data to my server (TServerSocket). The data transmitted are a plain string with delimeted strings.

The client / server works fine, but at times it is a requirement that the client will really rapidly send data to the server ... With my testing it seems as if the data gets "lost".

For example, I transmit these strings, lets say, five different messages, directly after each other. When inspecting my database, I see that only two of them gets recorded. Should I, for testing purposes, perform a Sleep(500), between the transmitions of these strings, all is fine.

Any pointers will be appreciated.

Thanx in advance.
EngwiAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Wim ten BrinkSelf-employed developerCommented:
No, sleeps should not be required unless client nd server are ont the same system. Even then, I would use Sleep(0) instead of Sleep(500). Sleep(0) will just allow another thread to run it's cycle, thus if client and server are on the same system, the server thread would get a chance to read. If client and server are on different systems then it should not matter.
Maybe consider sending those multiple messages as one single, larger message...
0
EngwiAuthor Commented:
Workskop Alex

Thanks, indeed, my client and server are on same machine {Testing purposes}, and I just confirmed your comment with Sleep(0), the transmission was more successfulle this time round, although not 100% effective. From your comment then I do take it that the "sleeps" would not be required at all if client and server on different machine ??

I will award the points on your reply.

Thanks again.  
0
BlackTigerXCommented:
do you connect/send the string/disconnect every time? by doing this you would probably get 100% but it would be a bit slower

or do you keep the connection open and just send strings?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Wim ten BrinkSelf-employed developerCommented:
Sleeps are useless if client and server are on different systems. It's also useless if you use a multi-processor PC, since the sleep is only needed to give another process a bit of breathing space. But if you have more than one processor (e.g. with two PC's) then both client and server have their own breathing space.
For testing purposes it would be better to use two computers. But it isn't always a requirement. But if the server is too busy, it could happen that your connection will time-out in which case the message gets dropped. It should be possible to detect this time-out, btw. And if you detect a time-out, just resend the message again. Be aware that since you're doing something with a database on the server, this database stuff will most likely slow things down. What I would do in such a case is make sure that every message sent to the server is handled by it's own thread. But I guess you're already doing this.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.