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 


2 clients 1 server (winsock)

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
nwongfeiying
Grandmaster Cheater
Reputation: 2

Joined: 25 Jun 2007
Posts: 695

PostPosted: Sun Mar 29, 2009 9:44 pm    Post subject: 2 clients 1 server (winsock) Reply with quote

I'm working on creating a server with multiple clients and I've been presented with two methods to do this. Which one is better?

1. multiple threads
2. ioctlsocket

I have an idea of how to do it, but I'm not entirely sure. Someone shed some light?
Back to top
View user's profile Send private message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Sun Mar 29, 2009 10:32 pm    Post subject: Reply with quote

I would use multiple threads for simplicity.
_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
nwongfeiying
Grandmaster Cheater
Reputation: 2

Joined: 25 Jun 2007
Posts: 695

PostPosted: Sun Mar 29, 2009 11:27 pm    Post subject: Reply with quote

How would you use the multiple threads? Would you use a thread to loop accept or would you create a thread for each client (this could lead to problems as state by blankrider if there's a lot of clients)?
Back to top
View user's profile Send private message
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Sun Mar 29, 2009 11:30 pm    Post subject: Reply with quote

OOP
Back to top
View user's profile Send private message
Flyte
Peanuts!!!!
Reputation: 6

Joined: 19 Apr 2006
Posts: 1887
Location: Canada

PostPosted: Mon Mar 30, 2009 3:16 am    Post subject: Reply with quote

Here is a great reference for all things winsock: http://tangentsoft.net/wskfaq/

There are two primary methods to do what you want. It's based on either of the following functions:
accept() - http://tangentsoft.net/wskfaq/examples/basics/threaded-server.html
select() - http://tangentsoft.net/wskfaq/examples/basics/select-server.html

With the former being easier, and the latter being more effective if you expect a larger workload.
Back to top
View user's profile Send private message
Jani
Grandmaster Cheater
Reputation: 2

Joined: 29 Dec 2006
Posts: 804

PostPosted: Mon Mar 30, 2009 4:58 am    Post subject: Reply with quote

oib111 wrote:
I would use multiple threads for simplicity.
Just a side note: specially in bigger projects you'll be suffering from lack of performance. I prefer events in every way.
Back to top
View user's profile Send private message
nwongfeiying
Grandmaster Cheater
Reputation: 2

Joined: 25 Jun 2007
Posts: 695

PostPosted: Mon Mar 30, 2009 3:56 pm    Post subject: Reply with quote

Can I have code snippet anyone?
Back to top
View user's profile Send private message
sloppy
Expert Cheater
Reputation: 0

Joined: 17 Aug 2008
Posts: 123

PostPosted: Mon Mar 30, 2009 4:08 pm    Post subject: Reply with quote

http://msdn.microsoft.com/en-us/library/ms738545
Back to top
View user's profile Send private message
slippppppppp
Grandmaster Cheater
Reputation: 0

Joined: 08 Aug 2006
Posts: 929

PostPosted: Mon Mar 30, 2009 5:07 pm    Post subject: Reply with quote

Look, setup the server like a regular server, but for multi clients this is what you want to do. in the Listen part, you wanna make it keep looping without stopping. Then everytime a client connects, push the socket into a vector, and create a thread to recieve every packet for only that socket. Then if you want to just send a packet to one socket, access the vector, or send the packet to every client by accessing the vector.
Back to top
View user's profile Send private message AIM Address MSN Messenger
Flyte
Peanuts!!!!
Reputation: 6

Joined: 19 Apr 2006
Posts: 1887
Location: Canada

PostPosted: Mon Mar 30, 2009 6:17 pm    Post subject: Reply with quote

nwongfeiying wrote:
Can I have code snippet anyone?


Did you even read my post? Look at it again. Read it very carefully and look at all the links.
Back to top
View user's profile Send private message
nwongfeiying
Grandmaster Cheater
Reputation: 2

Joined: 25 Jun 2007
Posts: 695

PostPosted: Mon Mar 30, 2009 7:47 pm    Post subject: Reply with quote

Flyte wrote:
nwongfeiying wrote:
Can I have code snippet anyone?


Did you even read my post? Look at it again. Read it very carefully and look at all the links.


Sorry! I only visited the first link.
Back to top
View user's profile Send private message
Kerelmans
Advanced Cheater
Reputation: 0

Joined: 29 Oct 2007
Posts: 57

PostPosted: Tue Mar 31, 2009 10:07 am    Post subject: Reply with quote

What language? If it's .net then you better use a TcpListener and make a thread for each new client connection. Then store them into a class / list you you can handle them easily.

-Kerelmans
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