#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2004
    Posts
    12
    Rep Power
    0

    send a picture over TCP


    Hi,

    I am using python 2.3.3 and have installed PIL http://www.pythonware.com/products/pil/index.htm

    I need to send a picture over a tcp socket (jpg). I can't figure out how to do this. Opening the file using builtin open, storing it in a list. Marshal the list (dump =marshal.dumps(list)) and send it to the server. Then unmarshal it (list = marshal.loads(dump)), write the list to a file. Then pray it will be able to view it using xv doesnt sound as the right solution. Correct me if am wrong!

    This can't be so hard to accomplish!?
  2. #2
  3. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,638
    Rep Power
    4247
    Quick question here... why are you serializing the data. Why can't you simply send the raw image data over a socket connection. You could perhaps design your own little protocol if needed, something like this:
    IMAGE <imagename> SIZE xxxx
    <image data follows>

    That way the other end knows what the file name is and what size it should expect. It can then stream the remaining data to a file. You can perhaps add a checksum as well.
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2004
    Posts
    12
    Rep Power
    0
    Yeah that was what I was looking for Couldn't think right... 12 hours with programming screws up my head sometimes.

    Almost embarrising
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Posts
    186
    Rep Power
    0
    you should read a nice little slashdot post on over coding... more than 10 hours = bad buggy code... that is unless you are drinking because somehow druken code always seems to compile.

IMN logo majestic logo threadwatch logo seochat tools logo