Ask a Question related to UNIX Programming, Design and Development.
-
jahurt@hotmail.com #1
Full duplex socket communication
I'm trying to write client/server networking applications and I've hit
a bit of a snag. After establishing a connection between client and
server, data needs to flow asynchronously; that is, I want both the
client and server to be able to initiate data transfers to the other
node.
The select() function immediately comes to mind. If I understand this
function correctly, it can block until there is data to read or it's
safe to write. However, most of the time it will be safe to write and
there will be nothing for it to do. Then I'll need to call select()
again... and I'll have an ugly busy-waiting loop. Someone please tell
me if I'm wrong...
The only other solution I can think of would be to create a
multi-threaded application, which would create an entirely new set of
problems I don't want to think about right now. Thanks in advance...
jahurt@hotmail.com Guest
-
A (different) duplex printing issue?
I am having an OS X print issue that seems unique to Acrobat, and I would appreciate some advice. I have a Canon c2880 printer that has a... -
How to Print A PDF in Duplex mode
Hi all, I am new to Acrobat SDK. I am working with .NET and PHP, that deals well with COM Objects. I have a lot of PDF Documents, dinamically... -
Automatic Duplex Printing
Is it possible to embed printing preferences into a PDF? I'm creating an 2 page application that needs to be sent to several other employees at my... -
Socket.accept problem via Socket.for_fd($stdin.fileno)
Hi, I am experiencing a rather infuriating problem with Socket.accept on Windows XP. The problem exists when I try to create a Socket from... -
Distinguishing between socket buffer full & socket disconnected
I am using the IO::Select method can_write() to flow control the writing of a large amount of data to a socket, where the writer may well run ahead... -
Wayne Throop #2
Re: Full duplex socket communication
: [email]jahurt@hotmail.com[/email]
: I'm trying to write client/server networking applications and I've hit
: a bit of a snag. After establishing a connection between client and
: server, data needs to flow asynchronously; that is, I want both the
: client and server to be able to initiate data transfers to the other
: node.
:
: The select() function immediately comes to mind. If I understand this
: function correctly, it can block until there is data to read or it's
: safe to write. However, most of the time it will be safe to write and
: there will be nothing for it to do. Then I'll need to call select()
: again... and I'll have an ugly busy-waiting loop. Someone please
: tell me if I'm wrong...
Do you have anything to write? If not, why are you asking select
to wake you up when it's safe to write?
Hence: to avoid the busy loop, simply select only on the various inputs
if you have nothing to write: if you DO have something to write (and
need to ensure it's safe, ie, won't block) you could include the write
socket in the select; but then, you won't be in a busy loop, you'll
be writing something, then deciding what to wait on the next time.
Or put it this way: you select only on events for which you will have
work to do; if the only thing you would do for an event is wait some
more, you don't ask to wake up for that event, since you're already waiting.
Wayne Throop [email]throopw@sheol.org[/email] [url]http://sheol.org/throopw[/url]
Wayne Throop Guest
-
Eric Sosman #3
Re: Full duplex socket communication
[email]jahurt@hotmail.com[/email] wrote:
... but if select() is waiting for something, just how>
> Tobias Oed <tobias@physics.odu.edu> wrote in message news:<beffnu$4i1k1$1@ID-97389.news.dfncis.de>...>> > [email]jahurt@hotmail.com[/email] wrote:
> >> >> > > I'm trying to write client/server networking applications and I've hit
> > > a bit of a snag. After establishing a connection between client and
> > > server, data needs to flow asynchronously; that is, I want both the
> > > client and server to be able to initiate data transfers to the other
> > > node.
> > >
> > > The select() function immediately comes to mind. If I understand this
> > > function correctly, it can block until there is data to read or it's
> > > safe to write. However, most of the time it will be safe to write and
> > > there will be nothing for it to do. Then I'll need to call select()
> > > again... and I'll have an ugly busy-waiting loop. Someone please tell
> > > me if I'm wrong...
> > If you don't have anything to write don't include that file descriptor in
> > the set you pass to select.
> > Tobias
> Thanks for the reply... perhaps I wasn't clear in my description of
> the problem.
> Data needs to flow ansynchronously - that is, data could become
> available at any time for writing. If select() is waiting for a
> socket to become available for reading, then I can't write...
does data "become available" for writing? Your program is
sitting there, stuck in select() and doing nothing at all;
in particular, it's not generating any data to be written.
If your program is multi-threaded, with T1 stuck in select()
while T2 generates data for output, nothing's preventing T2
from writing its data whenever it pleases.
Summary: I still don't understand what's troubling you.
--
[email]Eric.Sosman@sun.com[/email]
Eric Sosman Guest
-
David Schwartz #4
Re: Full duplex socket communication
<jahurt@hotmail.com> wrote in message
news:d4ef389d.0307090916.58ecc3bd@posting.google.c om...
Definitely.> Thanks for the reply... perhaps I wasn't clear in my description of
> the problem.
How would data become available for writing exactly?> Data needs to flow ansynchronously - that is, data could become
> available at any time for writing.
Yes, but if 'select' is waiting for a socket to become available for> If select() is waiting for a
> socket to become available for reading, then I can't write...
reading, you can't do anything else at all. So where would this data that
became available for writing become available *from*?
I'm presuming we're not talking about multithreading. If you are, then
the thread that generates the data that needs to be written can either write
it itself or force the thread that's in 'select' to stop selecting (say by
sending a byte on a pipe it's also selecting on).
DS
David Schwartz Guest



Reply With Quote

