[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

why  the cpu usage goes to 100% when the the idtcpclient connects to idtcpserver

Posted on 2007-11-18
4
Medium Priority
?
929 Views
Last Modified: 2012-05-05
I did a simple program that connects a component tidtcpclient to tidtcpserver, but when it connects the server, on the server side the cpu usage goes to 100%, and stay on it, so why this happaning? and this is normal? i only connected, that's it.
0
Comment
Question by:rafaelrgl
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 28

Accepted Solution

by:
2266180 earned 1200 total points
ID: 20309173
I think I know what the problem is. you are not using the servers onexecute event, or are using it incorrectly.

all processing must be done in the server onexecute event using the parameter which identifies the thread (from which you get the connection object). that event is beeing executed in the context of that specific thread, so keep in mind that you will have to synchronize access to any shared resources.

if you don't want to use that event (I've had such an application myself where I just notified another thread of the existing data and the server processed it whenever it got time), you simply assign the event and in it you doo a sleep(5); (very small value).
this will make sure that :
- your server's client thread doesn't get blocked for too much time
- AND, the cpu is not used extensivly.

because what happens is that as long as there is some data to be read from the client end, the server will keep executing that event. so if you don't process data in it, it will be executed in a loop very fast ;)
0
 
LVL 17

Assisted Solution

by:TheRealLoki
TheRealLoki earned 400 total points
ID: 20309375
can you show us your server's code please.
I think Ciuly is right, you are probably using the OnConnect event instead of the OnExecute event.
0
 
LVL 19

Assisted Solution

by:MerijnB
MerijnB earned 400 total points
ID: 20311270
alternatively, if you are not familiar with sync programming, use something like ICS (free): http://www.overbyte.be/frame_index.html?redirTo=/products/ics.html
0
 
LVL 28

Expert Comment

by:2266180
ID: 20311348
(this is an addition/extension to merijnb's post)

it's not really sycn programming. indy uses blocking (synchronous) sockets whereas ics uses non-blocking (asyncronous) sockets. so it's not the programming style but the socket type. and in both cases, the basic style is to use events, the difference is the way those events are fired and processed. and of course that the socket type induces a certain programming style, but I for example have made 2 systems until today that can use blocking sockets in a non-blocking fashion. of course, the unrelying atomic data is a (n xml) command so the event is fired when such a command is available to be processed.
what I want to say is that no matter of the socket type you can use any programming style, but you'll just have to be carefull :)

basically, both types of sockets are best fit for specific types of applications (complementary). and as I said above, both types of sockets can be used in the other types of applications where they don't fit so well.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

649 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