guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Trouble w/sockets


From: mark
Subject: Re: Trouble w/sockets
Date: Sun, 03 Mar 2013 00:36:09 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux)

Mike Gran <address@hidden> writes:

>
> Crash? Or throw an error?  I definitely shouldn't crash, but, I could see
> how it could throw an error on Guile 2.0.

Sadly, it does crash. No error message at all, so it's probably a
segfault or something of that kind.

> The problem with `write-char' in Guile 2.0 is that it does all the
> conversion to the current locale.  So, once you start hitting the bytes
> greater than 127 in your string, `write-char' tries to convert each
> byte to something in your encoding.
>
> If your encoding is "C" or anything that strictly uses ASCII as its
> character encoding, it'll throw an error when its trying to print any
> byte above 127.  If your encoding is UTF-8, those high bytes will become
> two byte strings.
>
> Ideally you'd be able to use bytevectors or binary ports or some such.

Binary ports are nice to work with; the trouble I have is that in the
end it's still my job to write the "read" and "write!" functions that
interface with the underlying port, and there's no guarantee that I'll
do that right. Still, it confines a lot of potential problems to one or
two places.

> But you can also fake it by setting the port encoding to ISO-8859-1.
> In that encoding the characters 0 to 255 map one-to-one with the bytes
> from 0 to 255.
> (set-port-encoding! sock "ISO-8859-1")

That's a good point! Unfortunately the code I provided before still
crashes even if I add that line before doing any reading from the port.

I tried adding buffering to the port, and now when I attempt to read
from it after writing the message and flushing it, I get an error that
the "resource is temporarily unavailable." Perhaps there's something I
need to do before connecting to the X server to ensure that it doesn't
hang up on me. Time to go look at the xcb C source code again...

> Hope this helps,

Thanks, I think it will, despite my apparent frustration. These encoding
issues were likely to crop up later even if they aren't the cause of my
current troubles.

-- 
Mark Witmer



reply via email to

[Prev in Thread] Current Thread [Next in Thread]