tobytes() public method

public tobytes ( ) : System.Bytes
return System.Bytes
Example #1
0
 public ByteArray InPlaceAdd(MemoryView other)
 {
     lock (this) {
         _bytes.AddRange(other.tobytes());
         return(this);
     }
 }
Example #2
0
 public bool __eq__(CodeContext /*!*/ context, [NotNull] MemoryView value)
 {
     if (_buffer == null)
     {
         return(value._buffer == null);
     }
     // TODO: comparing flat bytes is oversimplification; besides, no data copyimg
     return(tobytes().Equals(value.tobytes()));
 }
Example #3
0
 public bool __eq__(CodeContext /*!*/ context, [NotNull] MemoryView value) => tobytes().Equals(value.tobytes());
Example #4
0
            public PythonTuple recvfrom_into(MemoryView buffer, [DefaultParameterValue(0)]int nbytes, [DefaultParameterValue(0)]int flags){
                
                int bytesRead;
                byte[] byteBuffer = buffer.tobytes().ToByteArray();
                IPEndPoint remoteIPEP = new IPEndPoint(IPAddress.Any, 0);
                EndPoint remoteEP = remoteIPEP;

                try {
                    bytesRead = _socket.ReceiveFrom(byteBuffer, (SocketFlags)flags, ref remoteEP);
                }
                catch (Exception e) {
                    throw MakeRecvException(e, SocketError.InvalidArgument);
                }

                buffer[new Slice(0, bytesRead)] = byteBuffer.Slice(new Slice(0, bytesRead));
                PythonTuple remoteAddress = EndPointToTuple((IPEndPoint)remoteEP);
                return PythonTuple.MakeTuple(bytesRead, remoteAddress);
            }
Example #5
0
            public int recv_into(MemoryView buffer, [DefaultParameterValue(0)]int nbytes, [DefaultParameterValue(0)]int flags) {
                int bytesRead;
                byte[] byteBuffer = buffer.tobytes().ToByteArray();
                try {
                    bytesRead = _socket.Receive(byteBuffer, (SocketFlags)flags);
                }
                catch (Exception e) {
                    if (_socket.SendTimeout == 0) {
                        var s = new SocketException((int)SocketError.NotConnected);
                        throw PythonExceptions.CreateThrowable(error(_context), (int)SocketError.NotConnected, s.Message);
                    }
                    else
                        throw MakeException(_context, e);

                }

                buffer[new Slice(0, bytesRead)] = byteBuffer.Slice(new Slice(0, bytesRead));
                return bytesRead;

            }
Example #6
0
 public static Bytes hexlify(MemoryView data)
 {
     return hexlify(data.tobytes());
 }