Flowdock
method

syswrite

Importance_0
syswrite(p1) public

No documentation

This method has no description. You can help the Ruby community by adding new notes.

Hide source
static VALUE
ossl_ssl_write(VALUE self, VALUE str)
{
    SSL *ssl;
    int nwrite = 0;
    rb_io_t *fptr;

    StringValue(str);
    Data_Get_Struct(self, SSL, ssl);
    GetOpenFile(ossl_ssl_get_io(self), fptr);

    if (ssl) {
        for (;;){
            nwrite = SSL_write(ssl, RSTRING_PTR(str), RSTRING_LEN(str));
            switch(ssl_get_error(ssl, nwrite)){
            case SSL_ERROR_NONE:
                goto end;
            case SSL_ERROR_WANT_WRITE:
                rb_io_wait_writable(FPTR_TO_FD(fptr));
                continue;
            case SSL_ERROR_WANT_READ:
                rb_io_wait_readable(FPTR_TO_FD(fptr));
                continue;
            case SSL_ERROR_SYSCALL:
                if (errno) rb_sys_fail(0);
            default:
                ossl_raise(eSSLError, "SSL_write:");
            }
        }
    }
    else {
        ID id_syswrite = rb_intern("syswrite");
        rb_warning("SSL session is not started yet.");
        return rb_funcall(ossl_ssl_get_io(self), id_syswrite, 1, str);
    }

  end:
    return INT2NUM(nwrite);
}
Register or log in to add new notes.