Re: client-server application question
- From: "Alexander Nickolov" <agnickolov@xxxxxxxx>
- Date: Mon, 20 Nov 2006 10:31:55 -0800
A true server won't send unsolicited packets. Instead,
you wait for your clients to send you keep-alive messages.
Those that didn't do that in timely manner (and you should
wait for a few failed keep-alives before you dismiss a
client) are presumed dead.
I'd recommend you the following book on WinSock:
Network Programming for Microsoft Windows, Second Edition
by Jim Ohlund, Anthony Jones, James Ohlund
http://www.amazon.com/dp/0735615799
--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnickolov@xxxxxxxx
MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================
"azsx" <radu_plugaru@xxxxxxxxx> wrote in message
news:1163792213.341565.147390@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Presumably your server already stores a list of connected
clients, at the very least that's the list of sockets it maintains.
If it doesn't you should change it so it does. You can use
getpeername to get the IP addres and port number of the
peer (client) for each socket.
Every thread i create when a new client arrives adds a new entry in a
map object.
As far as how many of these are alive - you can't get awayThis means that from time to time I should send data and wait for a
from active keep-alive pinging, since a TCP connection
with no data flowing can silently break at any time with
no indication for either peer until attempted data transmission
fails.
responce? I thought of that, but what if the connection speed with some
clients is small? Wouldn't that affect my process? How much time sould
I wait for an answer from the client? If I wait for all clients
responces and some client doesn't answer?
As for your design with a thread per client - this is very
inefficient for a client, but it is a pure disaster for a server.
Learn about the other socket models offered by WinSock.
For a server the ultimate model is overlapped I/O using
I/O Completion Port (IOCP).
How can I find out more about that? Please give me some links!
.
- Follow-Ups:
- Re: client-server application question
- From: azsx
- Re: client-server application question
- References:
- client-server application question
- From: azsx
- Re: client-server application question
- From: Alexander Nickolov
- Re: client-server application question
- From: azsx
- client-server application question
- Prev by Date: Re: NAT and keepaliveopen connection over TCP
- Next by Date: Re: Database Server based on SQL database
- Previous by thread: Re: client-server application question
- Next by thread: Re: client-server application question
- Index(es):
Relevant Pages
|
Loading