Code Comments
Programming Forum and web based access to our favorite programming groups.Hello, Lets say I made a client/server tcp solution where clients would connect to the server and use some resource on it. As usual it would be the client which would do the requests and the server would respond. However I'd like to expand my knowledge now to add some features to my client/server. Think of a MSN client. Lets say some friend on your list logs on, you will be notified of this and the guy/girl will appear as online on your list. I wonder how this is done? My thoughts are that there could be an additional incomming socket where the server sends the data on. But this doesn't make sense because then it wouldn't work so flawless with firewalls as it does. The other way would be that the client asks often "is there any data for me?" on the same socket which it also sends data to to the server. What I'm asking is how the client can act like a server and working as a client at the same time. The reason for my interest is because I want to queue clients on the server when it's full instead of saying "denied please wait". However this raises alot of questions which I havn't found answers for yet. Suppose the server becomes ready and wants to accept the next queued client and the client is lazy and doesn't react, what should then happen? Also are there some mechanism which are often used when performing queuing? If anyone could point me to some material or books on "advanced protocols" and not the usual simple echo-server I'd be most happy. Thanks in advance. -- John
Post Follow-up to this message"John Smith" <john.smith@x-formation.com> writes: > Hello, > > Lets say I made a client/server tcp solution where clients would connect t o > the server and use some resource on it. As usual it would be the client > which would do the requests and the server would respond. However I'd like > to expand my knowledge now to add some features to my client/server. > > Think of a MSN client. Lets say some friend on your list logs on, you will > be notified of this and the guy/girl will appear as online on your list. I > wonder how this is done? My thoughts are that there could be an additional > incomming socket where the server sends the data on. But this doesn't make > sense because then it wouldn't work so flawless with firewalls as it does. > The other way would be that the client asks often "is there any data for > me?" on the same socket which it also sends data to to the server. What I' m > asking is how the client can act like a server and working as a client at > the same time. Typically, one would use select() to wait for input from the server socket or the user. -- Måns Rullgård mru@mru.ath.cx
Post Follow-up to this message> Typically, one would use select() to wait for input from the server > socket or the user. Yes I figured select() could be used but it doesn't answer all of my questions unfortunatly. For this to be useful I assume the socket must be maintained in a seperate thread on the client. I'm thinking what would happen if a client wants to send data to server and select() is blocking. I'm missing the connection of how the client should both act as a server and as a client at the same time. In my case the server already uses select() only for this purpose to see if other clients are requesting stuff. Thanks in advance. -- John
Post Follow-up to this messageIn article <416f9dc0$0$170$edfadb0f@dread11.news.tele.dk>, "John Smith" <john.smith@x-formation.com> wrote: > > Yes I figured select() could be used but it doesn't answer all of my > questions unfortunatly. > For this to be useful I assume the socket must be maintained in a seperate > thread on the client. It could be, but it doesn't have to. If you use separate threads, you might not even need to use select(). One thread can block in read() on the socket, while another thread interacts with the user and sends on the socket. > I'm thinking what would happen if a client wants to send data to server an d > select() is blocking. I'm missing the connection of how the client should > both act as a server and as a client at the same time. In my case the serv er > already uses select() only for this purpose to see if other clients are > requesting stuff. Add the FD that interacts with the user into the select(). When the user types something, select() will report that this FD is readable, and then the client can send something to a remote system. -- Barry Margolin, barmar@alum.mit.edu Arlington, MA *** PLEASE post questions in newsgroups, not directly to me ***
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.