Problems Returning an HTTP 200 Ok Message
samwyse at gmail.com
Thu Jul 10 21:38:27 CEST 2008
On Jul 10, 1:50 pm, Guy Davidson <GDavids... at gmail.com> wrote:
> Hi Folks,
> I'm having some issues with an small socket based server I'm writing,
> and I was hoping I could get some help.
> My code (attached below) us supposed to read an HTTP Post message
> coming from a power meter, parse it, and return a proper HTTP 200 Ok
> message. The problem is that the socket fails to send the entire
> message as one message, creating a fragmented message which the power
> meter then fails to read and accept.
> Is there any way to force the socket to send the entire message at
> once? Am I doing anything wrong? Is there an easier way to implement
> this functionality?
By 'message', do you mean a single IP datagram? In general, the
answer is no. Each call to 'connection.send()' will (in general, see
the next paragraph) transmit as much data as will fit into a single IP
datagram, given the current MTU for the transmission circuit. The
fact that you're calling it in a loop indicates that the data being
sent may be larger than will fit into a datagram.
Or, by 'message', do you mean a single TCP segment? Again, the answer
is no. Your network stack will try to make the TCP segments the right
size to fit within a single IP datagram, leading to the same result as
From your description, I get the feeling that your power meter has a
broken network stack, and you're trying to program around it. You
need to repair the meter.
More information about the Python-list