Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.unix.programmer > #854

Re: socket programming. read from server.

From Eric Sosman <esosman@ieee-dot-org.invalid>
Newsgroups comp.unix.programmer
Subject Re: socket programming. read from server.
Date 2011-06-22 22:22 -0400
Organization A noiseless patient Spider
Message-ID <itu835$ads$1@dont-email.me> (permalink)
References <88dc219d-5c3e-4d01-8b32-5280eaffcd04@l6g2000vbn.googlegroups.com>

Show all headers | View raw


On 6/22/2011 9:37 AM, Steve Richter wrote:
> when a client reads from a socket, how does it know the server has
> completed sending and is itself currently blocking on a read from the
> client?

     By inferring it from the mutually agreed-upon protocol.  Ever
see disciplined use of a two-way radio?  On a TV cop show, perhaps?
Notice how the speaker always says "Over" to advertise that he's
finished speaking and will now listen?  And "Out" to indicate that
the conversation is finished?  (And the completely nonsensical "Over
and out" to indicate that the dialog was written by someone who's
never used a radio?)  Those messages are part of a protocol to manage
the communication, something decided before communication begins.
Your client and server must similarly decide on channel-management
protocols (simple or complex) beforehand.

> I am writing a small ftp client in C for the IBM AS400 using the UNIX
> APIs. When the client code connects to the FTP server it reads back
> the initial welcome messages. My code reads from the server, gets
> some /r terminated messages. Reads again and gets more /r terminated
> welcome messages. Then reads a 3rd time and blocks because there is
> nothing more to read.  What in the socket protocol tells me the 3rd
> read is going to block?

     If it's an FTP client, it must follow the FTP protocols as
described in the RFC's (GIYF).  If it doesn't follow those protocols
when the FTP servers expect it to, you can anticipate difficulties
of exactly the same kind you'd get if the radioman said "Repeat"
instead of "Out" and "Zooglobble" instead of "Over."

-- 
Eric Sosman
esosman@ieee-dot-org.invalid

Back to comp.unix.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

socket programming. read from server. Steve Richter <stephenrichter@gmail.com> - 2011-06-22 06:37 -0700
  Re: socket programming. read from server. Steve Richter <stephenrichter@gmail.com> - 2011-06-22 08:12 -0700
  Re: socket programming. read from server. Richard Kettlewell <rjk@greenend.org.uk> - 2011-06-22 16:31 +0100
  Re: socket programming. read from server. Rainer Weikusat <rweikusat@mssgmbh.com> - 2011-06-22 16:42 +0100
  Re: socket programming. read from server. David Schwartz <davids@webmaster.com> - 2011-06-22 09:00 -0700
    Re: socket programming. read from server. Steve Richter <stephenrichter@gmail.com> - 2011-06-22 09:05 -0700
  Re: socket programming. read from server. "Heinrich Wolf" <invalid@invalid.invalid> - 2011-06-22 22:50 +0200
  Re: socket programming. read from server. Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-06-22 22:22 -0400
    Re: socket programming. read from server. Michael Press <rubrum@pacbell.net> - 2011-06-24 14:08 -0700

csiph-web