示例#1
0
        public static void PerformModuleReload(PythonContext /*!*/ context, PythonDictionary /*!*/ dict)
        {
            var socket      = context.GetBuiltinModule("socket");
            var socketError = PythonSocket.GetSocketError(context, socket.__dict__);

            context.EnsureModuleException("SSLError", socketError, dict, "SSLError", "ssl");
        }
示例#2
0
            public object read(CodeContext /*!*/ context, int len, ByteArray buffer = null)
            {
                EnsureSslStream(true);

                try {
                    byte[]       buf    = new byte[2048];
                    MemoryStream result = new MemoryStream(len);
                    while (true)
                    {
                        int readLength = (len < buf.Length) ? len : buf.Length;
                        int bytes      = _sslStream.Read(buf, 0, readLength);
                        if (bytes > 0)
                        {
                            result.Write(buf, 0, bytes);
                            len -= bytes;
                        }

                        if (bytes == 0 || len == 0 || bytes < readLength)
                        {
                            var res = result.ToArray();
                            if (buffer == null)
                            {
                                return(Bytes.Make(res));
                            }

                            // TODO: get rid of the MemoryStream and write directly to the buffer
                            buffer[new Slice(0, res.Length)] = res;
                            return(res.Length);
                        }
                    }
                } catch (Exception e) {
                    throw PythonSocket.MakeException(context, e);
                }
            }
示例#3
0
 public static void PerformModuleReload(PythonContext/*!*/ context, PythonDictionary/*!*/ dict) {            
     var socket = context.GetBuiltinModule("_socket");
     var socketError = PythonSocket.GetSocketError(context, socket.__dict__);
     
     var sslError = context.EnsureModuleException("SSLError", socketError, dict, "SSLError", "ssl");
     context.EnsureModuleException("SSLZeroReturnError", sslError, dict, "SSLZeroReturnError", "ssl");
     context.EnsureModuleException("SSLWantWriteError", sslError, dict, "SSLWantWriteError", "ssl");
     context.EnsureModuleException("SSLSyscallError", sslError, dict, "SSLSyscallError", "ssl");
     context.EnsureModuleException("SSLEOFError", sslError, dict, "SSLEOFError", "ssl");
     context.EnsureModuleException("SSLWantReadError", sslError, dict, "SSLWantReadError", "ssl");
 }
示例#4
0
            public int write(CodeContext /*!*/ context, Bytes data)
            {
                EnsureSslStream(true);

                byte[] buffer = data.UnsafeByteArray;
                try {
                    _sslStream.Write(buffer);
                    return(buffer.Length);
                } catch (Exception e) {
                    throw PythonSocket.MakeException(context, e);
                }
            }