socket module - recv() method



Currently using the following technique in serveral client
applications to send a request message and receive a response:

import socket
bufferSize = 500000
connectionHandle = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
connectionHandle.connect(sa)
connectionHandle.sendall(requestMessage)
fullResponse = ''
# use while loop in case the entire response not sent in one chunk
while (1):
response = connectionHandle.recv(bufferSize)
fullResponse = fullResponse + response
if fullResponse.find(endOfMessageText) != -1:
break

where:
sa = 2-element tuple; 1st elem is string denoting ip address; 2nd elem
is int denoting port
requestMessage = string containing request message
endOfMessageText = string that unambiguously denotes the end of
response message

All of the client apps on which this technique is employed are very
predictable in the sense that the client apps always know in advance
the value of endOfMessageText.

Questions:
1) is it theoretically possible that a client app will want to send a
request and receive a response where the response message does not
have something that unambigusously marks its end?
2) if so, are there any best-practices techniques for constructing the
code such that the client app knows that there is nothing else in the
response message?

Thank you.

.



Relevant Pages

  • Re: Client/Service relationships & Flow of Requirements.
    ... the client calls "foo" when it wants "bar" to return a particular value. ... The following is designed to compel Prey objects to do something: ... predator < 100 yards from prey ... It is the expectation of the response that makes the runFrom name immediately suspect in an OO context. ...
    (comp.object)
  • Re: [Full-disclosure] [Professional IT Security Providers -Exposed] PlanNetGroup ( F )
    ... the review a second time and incorporate some of your suggestions. ... to do what the client will pay him for. ... exactly a vulnerability assessment is... ... Your response to question 3: ...
    (Full-Disclosure)
  • Re: Debain on the rise ! - However ....
    ... >> Maybe I'll be able to give Debian a try at some point in the future, ... Most threads get response. ... > client shouldn't bitch that they get burned by volume. ... > chance HTML email has content, ...
    (Debian-User)
  • Re: Socket write behaviour is inconsistent?
    ... copy 1 byte to buffer, copy many bytes to buffer, copy one byte to ... Then why did you write "the client throws an error"? ... remote endpoint for your connection. ... When the response is sent using the first chunk of code, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Message-based vs. method-based interaction [was: Re: LSP and subtype]
    ... That means the sender implementation does not to know about the response, much less depend in any way on what the responder does, so LSP becomes academic. ... Separation of message and method allows one to design both the client and the service independently. ... Then the entire LSP issue comes down to determining where in the subclassing tree the client should access. ... To do that one needs the OOA/D mindset that clients generate messages, ...
    (comp.object)