[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.c

reading from a socket

Steve Richter

6/22/2011 1:28:00 PM

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?

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?

thanks,
57 Answers

Barry Briggs

6/22/2011 1:33:00 PM

0

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?
>
> I am writing a small ftp client in C for the IBM AS400 using the UNIX
> APIs.

Hello,

This is the wrong newsgroup. comp.unix.programmer is the group you want.

Regards.

Steve Richter

6/22/2011 1:39:00 PM

0

On Jun 22, 9:32 am, Noob <r...@127.0.0.1> wrote:
> 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?
>
> > I am writing a small ftp client in C for the IBM AS400 using the UNIX
> > APIs.
>
> Hello,
>
> This is the wrong newsgroup. comp.unix.programmer is the group you want.
>
> Regards.

ok. reposted on comp.unix.programmer

thanks,

cr88192

6/22/2011 3:16:00 PM

0

On 6/22/2011 6:38 AM, Steve Richter wrote:
> On Jun 22, 9:32 am, Noob<r...@127.0.0.1> wrote:
>> 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?
>>
>>> I am writing a small ftp client in C for the IBM AS400 using the UNIX
>>> APIs.
>>
>> Hello,
>>
>> This is the wrong newsgroup. comp.unix.programmer is the group you want.
>>
>> Regards.
>
> ok. reposted on comp.unix.programmer
>

yep... because for who knows what reason, the people here generally
exclude/reject anything not related to the C standard, and most topics
related to actually using the language (which necessarily either involve
OS-specific details, or other details not directly revolving around the
C standard...).

in a way it is silly/stupid, but whatever...

John Gordon

6/22/2011 3:33:00 PM

0

In <itt15q$64k$1@news.albasani.net> BGB <cr88192@hotmail.com> writes:

> yep... because for who knows what reason, the people here generally
> exclude/reject anything not related to the C standard, and most topics
> related to actually using the language (which necessarily either involve
> OS-specific details, or other details not directly revolving around the
> C standard...).

> in a way it is silly/stupid, but whatever...

It is not "silly" to suggest that a discussion be taken to where the
experts are.

You can discuss retirement planning with your dentist, and he might
actually know something about it, but you'll likely get better advice
from a retirement palnner.

--
John Gordon A is for Amy, who fell down the stairs
gordon@panix.com B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"

cr88192

6/22/2011 3:55:00 PM

0

On 6/22/2011 8:33 AM, John Gordon wrote:
> In<itt15q$64k$1@news.albasani.net> BGB<cr88192@hotmail.com> writes:
>
>> yep... because for who knows what reason, the people here generally
>> exclude/reject anything not related to the C standard, and most topics
>> related to actually using the language (which necessarily either involve
>> OS-specific details, or other details not directly revolving around the
>> C standard...).
>
>> in a way it is silly/stupid, but whatever...
>
> It is not "silly" to suggest that a discussion be taken to where the
> experts are.
>
> You can discuss retirement planning with your dentist, and he might
> actually know something about it, but you'll likely get better advice
> from a retirement palnner.
>

except when asking questions that are sufficiently generic to where most
people will know the answer (unless they live in a hole or
something...), or which are not strictly topical in any relevant newsgroup.

it is silly that people start waving "off topic" around as soon as the
conversation goes outside "well, the C standard says this..." and random
newbies doing Q/A about newbie issues related to the C standard ("why
cast pointer between incompatible types no work?...", ...).

the only real sane explanation is for volume control, but it smells like
many people have sticks shoved somewhere, which isn't really ideal...

much like people making a big fuss over "little detail not guaranteed by
the standard" even if "liable to work for any sane target one is
probably going to want to build their code for", or putting up a giant
fuss over "implementation details" related to how a given feature works
on a given target. AKA: "ultra-portability", where portability
requirements are assumed to extend beyond the N combinations of CPU and
OS which are the stated targets of a given program (for example, if a
program is only intended to be used on Windows on 32-bit x86, then picky
little thins about "well, relying on 8-bit chars may not work on some
esoteric embedded system"/... are not terribly relevant, since, after
all, the code is only intended to run on a single target anyways, but
issues about, say, behavior of WoW64/... may be relevant).


all of which are relevant to "actually using the language for writing
actual code", which itself isn't topical, since apparently it is a group
more for newbie Q/A than for anyone actually using the language for
anything.


or such...

Keith Thompson

6/22/2011 4:18:00 PM

0

BGB <cr88192@hotmail.com> writes:
> On 6/22/2011 6:38 AM, Steve Richter wrote:
>> On Jun 22, 9:32 am, Noob<r...@127.0.0.1> wrote:
>>> 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?
>>>
>>>> I am writing a small ftp client in C for the IBM AS400 using the UNIX
>>>> APIs.
>>>
>>> This is the wrong newsgroup. comp.unix.programmer is the group you want.
>>>
>> ok. reposted on comp.unix.programmer
>
> yep... because for who knows what reason, the people here generally
> exclude/reject anything not related to the C standard, and most topics
> related to actually using the language (which necessarily either involve
> OS-specific details, or other details not directly revolving around the
> C standard...).
>
> in a way it is silly/stupid, but whatever...

The question really is Unix-specific. comp.unix.programmer is an
active newsgroup, full of experts who know more about sockets than,
for example, I do. Steve will get *better answers* there than he
would here.

Why would you want him to post here instead?

--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.ne...
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"

cr88192

6/22/2011 4:29:00 PM

0

On 6/22/2011 9:17 AM, Keith Thompson wrote:
> BGB<cr88192@hotmail.com> writes:
>> On 6/22/2011 6:38 AM, Steve Richter wrote:
>>> On Jun 22, 9:32 am, Noob<r...@127.0.0.1> wrote:
>>>> 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?
>>>>
>>>>> I am writing a small ftp client in C for the IBM AS400 using the UNIX
>>>>> APIs.
>>>>
>>>> This is the wrong newsgroup. comp.unix.programmer is the group you want.
>>>>
>>> ok. reposted on comp.unix.programmer
>>
>> yep... because for who knows what reason, the people here generally
>> exclude/reject anything not related to the C standard, and most topics
>> related to actually using the language (which necessarily either involve
>> OS-specific details, or other details not directly revolving around the
>> C standard...).
>>
>> in a way it is silly/stupid, but whatever...
>
> The question really is Unix-specific. comp.unix.programmer is an
> active newsgroup, full of experts who know more about sockets than,
> for example, I do. Steve will get *better answers* there than he
> would here.
>
> Why would you want him to post here instead?
>

well, one can also post on other groups...
but, simply being like "OT here, go post over there" is not very
helpful, especially for something trivial, where someone could have just
responded:
"ok, go look up 'fcntl()' and O_NONBLOCK" or "ioctl() and FIONBIO" or
similar, which would presumably have been more helpful answers, and is
reasonably portable (which works on POSIX systems, and is "reasonably
similar" for Winsock, just with "ioctlsocket()" instead of "ioctl()", ...).

so, really, there is no reason to redirect, and a general answer could
have been given which would have extended to the vast majority of
existing operating systems...


it is about like redirecting someone to a different group for the
difference between '\\' and '/' as a path separator. it is silly and
pointless...

better is to try to give helpful responses, rather than having the
default answer be "OT here, go ask somewhere else...".


or such...

John Gordon

6/22/2011 4:52:00 PM

0

In <itt5fd$fvc$1@news.albasani.net> BGB <cr88192@hotmail.com> writes:

> "ok, go look up 'fcntl()' and O_NONBLOCK" or "ioctl() and FIONBIO" or
> similar, which would presumably have been more helpful answers, and is
> reasonably portable (which works on POSIX systems, and is "reasonably
> similar" for Winsock, just with "ioctlsocket()" instead of "ioctl()", ...).

It's kind of funny that, even in your own example, you had to detour
into system-specific details.

> better is to try to give helpful responses, rather than having the
> default answer be "OT here, go ask somewhere else...".

If ask my dentist about retirement planning, the most helpful answer he
can give me is "go talk to a retirement planner."

--
John Gordon A is for Amy, who fell down the stairs
gordon@panix.com B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"

Ben Bacarisse

6/22/2011 4:55:00 PM

0

BGB <cr88192@hotmail.com> writes:

> On 6/22/2011 9:17 AM, Keith Thompson wrote:
>> BGB<cr88192@hotmail.com> writes:
>>> On 6/22/2011 6:38 AM, Steve Richter wrote:
>>>> On Jun 22, 9:32 am, Noob<r...@127.0.0.1> wrote:
>>>>> 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?
>>>>>
>>>>>> I am writing a small ftp client in C for the IBM AS400 using the UNIX
>>>>>> APIs.
>>>>>
>>>>> This is the wrong newsgroup. comp.unix.programmer is the group you want.
>>>>>
>>>> ok. reposted on comp.unix.programmer
>>>
>>> yep... because for who knows what reason, the people here generally
>>> exclude/reject anything not related to the C standard, and most topics
>>> related to actually using the language (which necessarily either involve
>>> OS-specific details, or other details not directly revolving around the
>>> C standard...).
>>>
>>> in a way it is silly/stupid, but whatever...
>>
>> The question really is Unix-specific. comp.unix.programmer is an
>> active newsgroup, full of experts who know more about sockets than,
>> for example, I do. Steve will get *better answers* there than he
>> would here.
>>
>> Why would you want him to post here instead?
>>
>
> well, one can also post on other groups...
> but, simply being like "OT here, go post over there" is not very
> helpful, especially for something trivial, where someone could have
> just responded:
> "ok, go look up 'fcntl()' and O_NONBLOCK" or "ioctl() and FIONBIO" or
> similar, which would presumably have been more helpful answers, and is
> reasonably portable (which works on POSIX systems, and is "reasonably
> similar" for Winsock, just with "ioctlsocket()" instead of "ioctl()",
> ...).

That does not answer the OP's question. Are you sure someone here would
know how to correct that reply? It's much more likely that such a
correction would happen in comp.unix.programmer.

> so, really, there is no reason to redirect, and a general answer could
> have been given which would have extended to the vast majority of
> existing operating systems...
>
> it is about like redirecting someone to a different group for the
> difference between '\\' and '/' as a path separator. it is silly and
> pointless...
>
> better is to try to give helpful responses, rather than having the
> default answer be "OT here, go ask somewhere else...".

Some answers might lead the OP astray. Almost by definition, the OP
does not know what the right answer is and a wrong one that goes
uncorrected might lead to all sorts of unnecessary convolutions in the
code.

> or such...

Eh?

--
Ben.

John Gordon

6/22/2011 5:38:00 PM

0

In <itt3g6$bhq$1@news.albasani.net> BGB <cr88192@hotmail.com> writes:

> it is silly that people start waving "off topic" around as soon as the
> conversation goes outside "well, the C standard says this..." and random
> newbies doing Q/A about newbie issues related to the C standard ("why
> cast pointer between incompatible types no work?...", ...).

You seem to be assuming that people *could* have answered the question
but chose not to, simply because it's off-topic for this group.

If a socket expert was reading this group and saw the question, I'm sure
they could have answered it and set the message headers so the answer
would appear here and also in a socket-appropriate group, and any further
discussion would then continue in that other group.

However, in the absence of such an expert, the best answer we can give,
and the answer we DID give, is to go ask somewhere else. Why is that so
bad?

--
John Gordon A is for Amy, who fell down the stairs
gordon@panix.com B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"