//send peer credentials null byte
		//different platforms do this in different ways
#if HAVE_CMSGCRED
		unsafe void WriteBsdCred ()
		{
			//null credentials byte
			byte buf = 0;

			IOVector iov = new IOVector ();
			//iov.Base = (IntPtr)(&buf);
			iov.Base = &buf;
			iov.Length = 1;

			msghdr msg = new msghdr ();
			msg.msg_iov = &iov;
			msg.msg_iovlen = 1;

			cmsg cm = new cmsg ();
			msg.msg_control = (IntPtr)(&cm);
			msg.msg_controllen = (uint)sizeof (cmsg);
			cm.hdr.cmsg_len = (uint)sizeof (cmsg);
			cm.hdr.cmsg_level = 0xffff; //SOL_SOCKET
			cm.hdr.cmsg_type = 0x03; //SCM_CREDS

			int written = socket.SendMsg (&msg, 0);
			if (written != 1)
				throw new Exception ("Failed to write credentials");
		}
示例#2
0
 static unsafe extern SSizeT writev(int fd, IOVector* iov, int iovcnt);
示例#3
0
 static unsafe extern SSizeT readv(int fd, IOVector* iov, int iovcnt);
示例#4
0
        public int WriteV(IOVector* iov, int count)
        {
            //FIXME: Handle EINTR here or elsewhere
            //FIXME: handle r != count
            //TODO: check offset correctness

            int r = (int)writev (Handle, iov, count);
            if (r < 0)
                throw UnixError.GetLastUnixException ();

            return r;
        }
示例#5
0
 public int Write(IOVector[] iov)
 {
     return Write (iov, 0, iov.Length);
 }
示例#6
0
        public int Write(IOVector[] iov, int offset, int count)
        {
            //FIXME: Handle EINTR here or elsewhere
            //FIXME: handle r != count
            //TODO: check offset correctness

            fixed (IOVector* bufP = &iov[offset]) {
                int r = (int)writev (Handle, bufP + offset, count);
                if (r < 0)
                    throw UnixError.GetLastUnixException ();

                return r;
            }
        }