Error when display socekt content

M

myzhang

Hello all,

The displayed string looks like some wierd chars (unreadable to human
being at all), when I tried to display the received message by socket.
I read by this line:
body = self.io.blockingRead (int(header.getFieldCN
('Content-Length')))
print "socket content: " + body

I am new to python, could you tell me where I did wrong?

Thank you,

Michael
 
P

Peter Hansen

The displayed string looks like some wierd chars (unreadable to human
being at all), when I tried to display the received message by socket.
I read by this line:
body = self.io.blockingRead (int(header.getFieldCN
('Content-Length')))
print "socket content: " + body

I am new to python, could you tell me where I did wrong?

You didn't post enough information for anyone to help much, that's
what...

Most importantly, what did you *expect* the above to do? For
all I can tell, you should have expected it to print
"socket content: " followed by some potentially unreadable
data, which is what you got...

Also, it will help if you describe what "self.io" is, what
"header.getFieldCN" is, and what kind of communications protocol
is involved in what you're doing. And, if it's HTTP as it
appears it might be, perhaps explain why you aren't using
something simple like urllib2 to deal with it...

Mentioning what platform (versions of OS and Python) you
are using is always a good idea too.

Cutting and pasting the *actual* output, or something
that describes a little better what you actually got and
what you expected to get is also a good idea... give us
enough information to help you and you'll be helping yourself.

-Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,219
Messages
2,571,127
Members
47,744
Latest member
FrederickM

Latest Threads

Top