From: Panagiotis Atmatzidis Date: 2013-06-04T03:47:39+09:00 Subject: TCPServer/Socket and Marshal problem Hello, I'm writing a client/server application using TCPSocket and TCPServer. To serialize the objects at this point I use Marshal, since it comes handy. However, at some point I need to make an array of elements extracted from a MySQL database (server side). I can see the list of UTF-8 Greek chars that is created, it's of class array and looks pretty much as it should. However when I serialized it using either Marshal or YAML and send it to the client, the client exists with this error: ############################################## ~/Code/Glucose » ruby client.rb "\x04\b[\n" client.rb:41:in `load': marshal data too short (ArgumentError) ############################################## On server side the Marshalled data looks like this: ############################################## [user@server ~/Code/Project]$ ruby server.rb ["Ααλή", "Ααρών", "αάτρευτα", "αάτρευτε", "Άαχεν"] Array "Marshalled \x04\b[\nI\"\r\xCE\x91\xCE\xB1\xCE\xBB\xCE\xAE\x06:\x06ETI\"\x0F\xCE\x91\xCE\xB1\xCF\x81\xCF\x8E\xCE\xBD\x06;\x00TI\"\x15\xCE\xB1\xCE\xAC\xCF\x84\xCF\x81\xCE\xB5\xCF\x85\xCF\x84\xCE\xB1\x06;\x00TI\"\x15\xCE\xB1\xCE\xAC\xCF\x84\xCF\x81\xCE\xB5\xCF\x85\xCF\x84\xCE\xB5\x06;\x00TI\"\x0F\xCE\x86\xCE\xB1\xCF\x87\xCE\xB5\xCE\xBD\x06;\x00T" ############################################## What I notice is that connection ends when the '\n' character appears. I think that the issue is me using "@con.gets" method instead of something more appropriate. I tried @con.read but since 'read' method waits for the remote party to send an 'EOF' or close the connection stalls. Is there any other method I can use instead of gets? I did a 'methods.sort' but I can't see and I don't know how to read about these methods using "ri". 'ri TCPSocket::getc' for example doesn't work. Any ideas and/or thoughts are welcomed, thanks for your time Best Regards, Panagiotis (atmosx) Atmatzidis email: atma@convalesco.org URL: http://www.convalesco.org GnuPG ID: 0x1A7BFEC5 gpg --keyserver pgp.mit.edu --recv-keys 1A7BFEC5 -- The wise man said: "Never argue with an idiot. They bring you down to their level and beat you with experience."