BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to manage a connection queue ?

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Internet Winsock
View previous topic :: View next topic  
Author Message
Grosno
Guest





PostPosted: Tue Feb 17, 2004 12:57 am    Post subject: How to manage a connection queue ? Reply with quote



Hye all !

I'm writing a server application based on custom implemntation of
non-blocking windows sockets.
For each accepted socket, I create a thread calling receive & send function
of the socket in a repeat until loop. Due do bandwith limit, I must manage a
connection queue. But I've no idea how to code that...
Have you an idea ?

Thanks by advance.

Gros


Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Tue Feb 17, 2004 3:06 am    Post subject: Re: How to manage a connection queue ? Reply with quote




"Grosno" <forumNFSPAM (AT) grosno (DOT) net> wrote


Quote:
For each accepted socket, I create a thread

Why are you using non-blocking then? If each client has its own thread,
then non-blocking will be harder, not easier, to manage. Blocking mode
works better when threads are involved.

Quote:
Due do bandwith limit, I must manage a connection queue.

What do you mean exactly? Only allowing one socket to actually read or
write at a time? If so, then you shouldn't be using threads for that to
begin with. Again, you are in a situation where you are making things
harder to manage than they should be.


Gambit



Back to top
GrosNo
Guest





PostPosted: Tue Feb 17, 2004 1:33 pm    Post subject: Re: How to manage a connection queue ? Reply with quote



"Remy Lebeau (TeamB)" <gambit47.no.spam (AT) no (DOT) spam.yahoo.com> a écrit dans le
message de news:40318361$1 (AT) newsgroups (DOT) borland.com...
Quote:

"Grosno" <forumNFSPAM (AT) grosno (DOT) net> wrote in message
news:403166d5 (AT) newsgroups (DOT) borland.com...

For each accepted socket, I create a thread

Why are you using non-blocking then? If each client has its own thread,
then non-blocking will be harder, not easier, to manage. Blocking mode
works better when threads are involved.

Cause I thought there is a limit of socket per thread (like 64 if I
remember), so I must in all case work with multithread, even I use non
blocking socket.
The Winsock implementation I use works with non blocking socket, and I
"must" work with it... (i don't know if the modification takes much time)
Quote:

Due do bandwith limit, I must manage a connection queue.

What do you mean exactly? Only allowing one socket to actually read or
write at a time? If so, then you shouldn't be using threads for that to
begin with. Again, you are in a situation where you are making things
harder to manage than they should be.

No, I just want that not too much client send data at the same to the
server... So I accept connection but I send a command to say that client
must wait before sending data...

Thanks for your answer.
Quote:


Gambit





Back to top
Chad Z. Hower aka Kudzu
Guest





PostPosted: Tue Feb 17, 2004 6:59 pm    Post subject: Re: How to manage a connection queue ? Reply with quote

"GrosNo" <niakNOSPAME (AT) grosno (DOT) net> wrote in
news:4032181c (AT) newsgroups (DOT) borland.com:
Quote:
Cause I thought there is a limit of socket per thread (like 64 if I
remember), so I must in all case work with multithread, even I use non

For some calls yes.



--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"

Qualified help FAST with Indy Experts Support
from the experts themselves:

http://www.atozed.com/indy/experts/support.iwp

Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Tue Feb 17, 2004 8:00 pm    Post subject: Re: How to manage a connection queue ? Reply with quote


"GrosNo" <niakNOSPAME (AT) grosno (DOT) net> wrote


Quote:
Cause I thought there is a limit of socket per thread
(like 64 if I remember)

It is possible to run hundreds of sockets at a time if you are using
multiple threads.

Quote:
No, I just want that not too much client send data at the same
to the server... So I accept connection but I send a command
to say that client must wait before sending data...

What you are asking for sounds like throttling. Simply slow down the
threads from accessing their sockets. That could be simple as calling
Sleep() periodically. If that is not what you are actually suggesting, then
please explain your situation in more detail.


Gambit



Back to top
Gros
Guest





PostPosted: Fri Feb 20, 2004 9:47 am    Post subject: Re: How to manage a connection queue ? Reply with quote

Ok, my explanations were bads...
I'm in a service application using non-blocking sockets.
My application must deal with more than 64 users at time, so my server must
be multithreaded.
Each client must send a large amount of data, with the shortest connection
time as possible. (clients connect with RTC and they pay for that).
Imagine I've 100 clients connecting at the same time. All send data to the
server. The bandwith will limit the transfert speed for each client to a
very small value, and then each client connection will spend a lot of time.
If I decide that only 10 clients of the 100 send data at the same time,
their connection will be shorter, no ? When one of the 10 sending data has
finish transfert, one of the first of the 90 waiting will start sending
data... and so on.
So I've 2 questions:
- Is it better to manage a thread per client socket or a thread for 64
clients who loop on the 64 sockets ?
- Is the connection queue realisable or not, and have you an idea on how to
code it ?

Thanks
Grosno

"Remy Lebeau (TeamB)" <gambit47.no.spam (AT) no (DOT) spam.yahoo.com> a écrit dans le
message de news:40327119$1 (AT) newsgroups (DOT) borland.com...
Quote:

"GrosNo" <niakNOSPAME (AT) grosno (DOT) net> wrote in message
news:4032181c (AT) newsgroups (DOT) borland.com...

Cause I thought there is a limit of socket per thread
(like 64 if I remember)

It is possible to run hundreds of sockets at a time if you are using
multiple threads.

No, I just want that not too much client send data at the same
to the server... So I accept connection but I send a command
to say that client must wait before sending data...

What you are asking for sounds like throttling. Simply slow down the
threads from accessing their sockets. That could be simple as calling
Sleep() periodically. If that is not what you are actually suggesting,
then
please explain your situation in more detail.


Gambit





Back to top
Atle Smelvær
Guest





PostPosted: Fri Feb 20, 2004 11:42 am    Post subject: Re: How to manage a connection queue ? Reply with quote

Is your server message handled, event handled or IOCP handled? How many
threads you must have depend on the architecture of your server.

To you have to manage 100, 1000 or 10000 connections, and how big is your
bandwidth?

-Atle


Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Fri Feb 20, 2004 9:15 pm    Post subject: Re: How to manage a connection queue ? Reply with quote


"Gros" <gros (AT) gros (DOT) net> wrote


Quote:
I'm in a service application using non-blocking sockets.
My application must deal with more than 64 users at time,
so my server must be multithreaded.

Then non-blocking is not the answer to begin with, since all socket
operations would be controlled by a single thread.

Quote:
Each client must send a large amount of data, with the shortest
connection time as possible.

Then use blocking sockets instead. They are better suited for that.

Quote:
clients connect with RTC and they pay for that

Windows is not a Real-Time OS to begin with, so you are not going to get
Real-Time performance no matter what you do in your code.

Quote:
- Is it better to manage a thread per client socket or a thread for
64 clients who loop on the 64 sockets ?

1 thread per client when possible. If system resources is an issue, then
perhaps you can use fibers and break the clients up into smaller groups.
That way, you can have a single fiber per client, and have a single thread
handling multiple fibers at a time, with multiple threads running to handle
multiple groups, but yet have fewer threads running overall.


Gambit



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Internet Winsock All times are GMT
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.