Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Client listening to requests from tcp server
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



Report this thread to moderator Post Follow-up to this message
Old Post
John Smith
10-12-04 08:58 PM


Re: Client listening to requests from tcp server
"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

Report this thread to moderator Post Follow-up to this message
Old Post
Måns Rullgård
10-12-04 08:58 PM


Re: Client listening to requests from tcp server
> 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



Report this thread to moderator Post Follow-up to this message
Old Post
John Smith
10-15-04 01:56 PM


Re: Client listening to requests from tcp server
In 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 ***

Report this thread to moderator Post Follow-up to this message
Old Post
Barry Margolin
10-16-04 08:56 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Unix Programming archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:57 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.