Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


So, I've got a bit of an issue with my socket server.

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Cheat Engine User
Something epic
Ban
Reputation: 61

Joined: 22 Jun 2007
Posts: 2071

PostPosted: Tue Dec 29, 2009 7:55 pm    Post subject: So, I've got a bit of an issue with my socket server. Reply with quote

It's going berserk on the CPU (load is around the 90 all the time). It's a multiclient one and it works fine but this CPU load worries me, is it a common problem/normal and what is causing it?

I am running on a Windows Server (2003 I believe) and I am using winsock (2.2)
Back to top
View user's profile Send private message
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Tue Dec 29, 2009 8:15 pm    Post subject: Reply with quote

Nope, it's not. Got any code to show us ?
Back to top
View user's profile Send private message
Cheat Engine User
Something epic
Ban
Reputation: 61

Joined: 22 Jun 2007
Posts: 2071

PostPosted: Tue Dec 29, 2009 8:22 pm    Post subject: Reply with quote

Slugsnack wrote:
Nope, it's not. Got any code to show us ?
Yes I do have the code to show it. But I have nothing to tell besides that I am looping in a while (in main()) and in that I first accept all clients, check for receiving stuff.

Code:
   while(LOOP)
   {
      t.check();
      accept_connections();
      receive_data();
   }


It's all that is currently interesting. t.check is a timer that checks if some time has passed and sends something to all clients if it did.
the rest is pretty obvious.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 475

Joined: 09 May 2003
Posts: 25985
Location: The netherlands

PostPosted: Tue Dec 29, 2009 9:06 pm    Post subject: Reply with quote

I think "select" might be of some use here
_________________
Tools give you results. Knowledge gives you control.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Cheat Engine User
Something epic
Ban
Reputation: 61

Joined: 22 Jun 2007
Posts: 2071

PostPosted: Tue Dec 29, 2009 11:00 pm    Post subject: Reply with quote

Dark Byte wrote:
I think "select" might be of some use here
Explain what you mean.
Back to top
View user's profile Send private message
tombana
Master Cheater
Reputation: 2

Joined: 14 Jun 2007
Posts: 456
Location: The Netherlands

PostPosted: Wed Dec 30, 2009 6:10 am    Post subject: Reply with quote

Holland wrote:
Dark Byte wrote:
I think "select" might be of some use here
Explain what you mean.

He means that normal winsock functions will block. That means that if you call recv() on a socket, it will hold your program until some data arrives. If you have multiple client then this will be a problem. So you can use the function 'select' to first check which clients have send data and then only call recv() on those specific sockets.

There are some other methods as well, they are listed here with their pros and cons:
http://tangentsoft.net/wskfaq/articles/io-strategies.html
It also depends on how many clients you will handle.
If you already have a window in your program I would strongly advise you to use asynchronous sockets because they are very easy to implement.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites