Nick Ing-Simmons <[EMAIL PROTECTED]> writes:
>Martin J. Evans <[EMAIL PROTECTED]> writes:
>>> 
>>> A socket is a file handle so :
>>> 
>>> binmode($sock,":utf8");
>>> 
>>> should work.
>>I'm obviously missing something rather fundamental here. 
>
>Not you - us.
>
>How can we have got this far without someone discovering this?
>
>binmmode() works on _input_ side of socket file handle:
>
>    if (!(io = GvIO(gv)) || !(fp = IoIFP(io))) {
>
>    if (PerlIO_binmode(aTHX_ fp,IoTYPE(io),mode_from_discipline(discp),
>                       (discp) ? SvPV_nolen(discp) : Nullch)) {
>
>There does not seem to be any way at all of setting layers on 
>output side of a bi-directional socket  :-(

Attached patch calls PerlIO_binmode() on IoOFP if it exists and
isn't same as IoIFP. It silences the warning on my quick-check
test.

-- 
Nick Ing-Simmons
http://www.ni-s.u-net.com/

--- pp_sys.c.ship       Tue Jul  1 12:55:32 2003
+++ pp_sys.c    Tue Jul  1 12:54:13 2003
@@ -742,6 +742,14 @@
     PUTBACK;
     if (PerlIO_binmode(aTHX_ fp,IoTYPE(io),mode_from_discipline(discp),
                        (discp) ? SvPV_nolen(discp) : Nullch)) {
+       if (IoOFP(io) && IoOFP(io) != IoIFP(io)) {
+            if (!PerlIO_binmode(aTHX_ IoOFP(io),IoTYPE(io),
+                       mode_from_discipline(discp),
+                       (discp) ? SvPV_nolen(discp) : Nullch)) {
+               SPAGAIN;
+               RETPUSHUNDEF;
+            }
+       }
        SPAGAIN;
        RETPUSHYES;
     }

Reply via email to