473,386 Members | 1,860 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Running a client-server interaction program

Hello,

What's the best way to run a client-server interaction using some
standardized protocol such as nntp?? That is, should you run a thread that
just does a receive loop from the server so that if the server sends
anything, it will be received? Or what about if everytime you send data,
then you do a receive; so if you were *expecting* something is the only time
to call a receive??

I think it's the former because then if anything, you are getting all the
messages the server is sending and you can parse/perform actions
accordingly... but I'm not so sure :-/

Thanks!

--
Regards,
Webster
Nov 20 '05 #1
4 1221
On 2004-01-29, Webster <we************@home.com> wrote:
Hello,

What's the best way to run a client-server interaction using some
standardized protocol such as nntp?? That is, should you run a thread that
just does a receive loop from the server so that if the server sends
anything, it will be received? Or what about if everytime you send data,
then you do a receive; so if you were *expecting* something is the only time
to call a receive??

I think it's the former because then if anything, you are getting all the
messages the server is sending and you can parse/perform actions
accordingly... but I'm not so sure :-/

Thanks!


I guess it really depends on what your trying to accomplish... But the
fact is that most standardized internet protocols - such as nntp use
your latter description...

For example, with NNTP the basic process is that the server waits on a
server listening for client connections on a known port. When a
connection is received, the server forks off a child process that gets a
new socket handle to communication with the client - then goes back
listening.

The child process then waits for commands from the client. When it
receives one, it obeys the order and returns a reply - which could be an
error... So basically, once the client sends the request it starts
trying to receive data - because it knows it is going to get some...

This is a very over simplified version of what's happening, so I hope it
makes sense...
--
Tom Shelton [MVP]
Powered By Gentoo Linux 1.4
He who knows others is wise.
He who knows himself is enlightened.
-- Lao Tsu
Nov 20 '05 #2
Cool thanks!

But there was a nntp server I logged into once that said it will log me out
after 10 seconds of being idle... So how could you know when the server is
going to send the disconnect command?? (unless you time it your self on your
end)

--
Regards,
Webster
"Tom Shelton" <to*@mtogden.com> wrote in message
news:eF**************@TK2MSFTNGP09.phx.gbl...
On 2004-01-29, Webster <we************@home.com> wrote:
Hello,

What's the best way to run a client-server interaction using some
standardized protocol such as nntp?? That is, should you run a thread that just does a receive loop from the server so that if the server sends
anything, it will be received? Or what about if everytime you send data,
then you do a receive; so if you were *expecting* something is the only time to call a receive??

I think it's the former because then if anything, you are getting all the messages the server is sending and you can parse/perform actions
accordingly... but I'm not so sure :-/

Thanks!


I guess it really depends on what your trying to accomplish... But the
fact is that most standardized internet protocols - such as nntp use
your latter description...

For example, with NNTP the basic process is that the server waits on a
server listening for client connections on a known port. When a
connection is received, the server forks off a child process that gets a
new socket handle to communication with the client - then goes back
listening.

The child process then waits for commands from the client. When it
receives one, it obeys the order and returns a reply - which could be an
error... So basically, once the client sends the request it starts
trying to receive data - because it knows it is going to get some...

This is a very over simplified version of what's happening, so I hope it
makes sense...
--
Tom Shelton [MVP]
Powered By Gentoo Linux 1.4
He who knows others is wise.
He who knows himself is enlightened.
-- Lao Tsu

Nov 20 '05 #3
In article <WX********************@news04.bloor.is.net.cable. rogers.com>, Webster wrote:
Cool thanks!

But there was a nntp server I logged into once that said it will log me out
after 10 seconds of being idle... So how could you know when the server is
going to send the disconnect command?? (unless you time it your self on your
end)


It probably wouldn't send a disconnect command... More than likely it
would just close the socket - expecting you to trap the exception or
detect a 0 return value from recv to know that the socket was closed...

--
Tom Shelton [MVP]
OS Name: Microsoft Windows XP Professional
OS Version: 5.1.2600 Service Pack 1 Build 2600
System Up Time: 2 Days, 2 Hours, 8 Minutes, 46 Seconds
Nov 20 '05 #4
"Tom Shelton" <to*@mtogden.com> wrote in message
news:OQ****************@TK2MSFTNGP09.phx.gbl...

It probably wouldn't send a disconnect command... More than likely it
would just close the socket - expecting you to trap the exception or
detect a 0 return value from recv to know that the socket was closed...


Oh I see... how rude!! ;-P

--
Regards,
Webster
Nov 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: gcash | last post by:
Most folks know you can start up an instance of Internet Explorer by saying "x=win32com.client.Dispatch('InternetExplorer.Application.1')" and you get a WIN32 object with a "Document" object that...
4
by: Jasleen | last post by:
I have written one Widows Service in ATL, having a ATL component running. Now it is very easy to create the VC client by calling CoCreateINstanceEx to create the component running in the service...
3
by: JezB | last post by:
Is it possible to have rich client and ASP.NET forms running side-by-side, with at least some method of communication between them (if shared memory is not viable) ?
10
by: ej1008 | last post by:
HI all I am having a windows Control running on ASP.Net webform. From this windows control I am trying to connect to database to do some database operations. Now I am facing problem while...
2
by: Tim Diggle | last post by:
I'm trying to enter data into a database application running under Citrix ICA Client. I'm doing it from a VBA macro running under Microsoft Excel 2000 (although it may need to be backwardly...
0
by: Uma | last post by:
Dear all, I have a problem while running a smart client application which was installed through CD-ROM. After installing the smart client setup the application is running properly. When running...
0
by: archana | last post by:
Hi all, I am having problem in one web method which i am running asynchronously I set oneway attribute in web method. What i want is once client called this web method this should start...
4
by: Jeremy S. | last post by:
We're in the process of writing a new Windows Forms app and the desktop support folks want for it to be run from a network share. I know it's possible (i.e., just have the framework on the clients...
2
by: jiccab | last post by:
Greetings. with the following code, olApp = Dispatch("Outlook.Application") I am capable of getting a new instance of Outlook running. I would like to be able to use the instance that is...
8
by: John | last post by:
Hi I am using the below code to run a sql on an underlying access table; insStr = "INSERT INTO ( Action, , , Request_Date ) " & _ "VALUES (""Modify Client"", 93, ""Administrator"", Now())"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.