FAQ
Slamming my head against what should be an easy problem:

How do I send a byte across an open, connected socket?

Do I have to implement my own type that implements some method a string
normally does?

Or is there some hidden encoding that will let me turn a byte into a
string?

This is surely a simple question for anyone who remembers the answer.

Thanks so much,
Dan

Search Discussions

  • Cliff Wells at Aug 27, 2003 at 6:53 am

    On Tue, 2003-08-26 at 23:38, Daniel Timothy Bentley wrote:
    Slamming my head against what should be an easy problem:

    How do I send a byte across an open, connected socket?

    Do I have to implement my own type that implements some method a string
    normally does?

    Or is there some hidden encoding that will let me turn a byte into a
    string?
    chr(byte)

    Regards,

    --
    Someone shot nostalgia in the back, someone shot our innocence
    -Bauhaus
  • Pettersen, Bjorn S at Aug 27, 2003 at 7:02 am

    From: Daniel Timothy Bentley [mailto:dbentley at stanford.edu]

    Slamming my head against what should be an easy problem:

    How do I send a byte across an open, connected socket?

    Do I have to implement my own type that implements some
    method a string
    normally does?

    Or is there some hidden encoding that will let me turn a byte into a
    string?

    This is surely a simple question for anyone who remembers the answer.
    A one character string is a byte...

    byteString = chr(byte)

    hth,
    -- bjorn
  • Andrew Bennetts at Aug 27, 2003 at 7:18 am

    On Wed, Aug 27, 2003 at 02:02:14AM -0500, Pettersen, Bjorn S wrote:
    From: Daniel Timothy Bentley [mailto:dbentley at stanford.edu]

    Slamming my head against what should be an easy problem:

    How do I send a byte across an open, connected socket?
    [...]
    A one character string is a byte...

    byteString = chr(byte)
    Calculating and sending single bytes at a time is probably unnecessarily
    painful, though. It wouldn't surprise me if the original poster finds that
    the struct module makes their life much easier:
    http://www.python.org/doc/lib/module-struct.html

    -Andrew.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedAug 27, '03 at 6:38a
activeAug 27, '03 at 7:18a
posts4
users4
websitepython.org

People

Translate

site design / logo © 2022 Grokbase