From: mark@markwitmer.com
To: Mike Gran <spk121@yahoo.com>
Cc: guile-user@gnu.org
Subject: Re: Trouble w/sockets
Date: Sun, 03 Mar 2013 00:36:09 -0500 [thread overview]
Message-ID: <87wqtp11va.fsf@markwitmer.com> (raw)
In-Reply-To: <1362286125.99740.YahooMailNeo@web120403.mail.ne1.yahoo.com> (Mike Gran's message of "Sat, 2 Mar 2013 20:48:45 -0800 (PST)")
Mike Gran <spk121@yahoo.com> 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
next prev parent reply other threads:[~2013-03-03 5:36 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-03 3:38 Trouble w/sockets mark
2013-03-03 4:48 ` Mike Gran
2013-03-03 5:36 ` mark [this message]
2013-03-03 6:35 ` Mike Gran
2013-03-03 7:29 ` Thien-Thi Nguyen
2013-03-04 4:18 ` mark.d.witmer
2013-03-04 4:38 ` mark.d.witmer
2013-03-04 10:02 ` Thien-Thi Nguyen
2013-03-03 10:36 ` Chris Vine
2013-03-04 13:29 ` Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87wqtp11va.fsf@markwitmer.com \
--to=mark@markwitmer.com \
--cc=guile-user@gnu.org \
--cc=spk121@yahoo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).