Re: client-server application question



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 away
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.
This means that from time to time I should send data and wait for a
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!



.



Relevant Pages

  • Re: Socket switch delay
    ... both at the client and at the server (and why ... would you set the send buffer size to zero on a non-overlapped ... One glaring error is your client does ... So when you use a single socket, ...
    (microsoft.public.win32.programmer.networks)
  • Re: Locking on async calls
    ... you must synchronize the entire SendMessage routine as an atomic ... operation to prevent mixed messages from being transmitted to the server. ... You are correct that read and write on the socket do not interfere with each ... If you want to handle multiple client connections from one server object ...
    (microsoft.public.dotnet.general)
  • Re: Design issue with WinSock/GetQueuedCompletionStatus
    ... delegate that to a shutdown routine called after all worker threads ... The application I've created is a server accepting connections on a few ... different TCP/IP ports and then lets the client run different commands. ... a TCP/IP socket can be closed for 2 different reasons: ...
    (microsoft.public.win32.programmer.networks)
  • Re: socket communication: socket doesnt connect
    ... Microsoft MVP, MCSD ... As far as your server code goes, ... accept the listening socket. ... Client client = new Client; ...
    (microsoft.public.vc.language)
  • Re: TCP server stop receiving new connections
    ... reset the event mask of your listening socket each time you ... I have a strange problem in my class library used by all our client ... server applications. ... incomming connections, but keeps current connections. ...
    (microsoft.public.win32.programmer.networks)

Loading