Client / Server question

Posted on 2004-11-19
Last Modified: 2010-04-05

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.
Question by:Engwi
    LVL 17

    Expert Comment

    by:Wim ten Brink
    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...

    Author Comment

    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.  
    LVL 13

    Accepted Solution

    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?
    LVL 17

    Expert Comment

    by:Wim ten Brink
    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.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
    In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now