Example #1
0
 internal static IPEndPoint EndPointFromAddressPtr(IntPtr address)
 {
     using (var buffer = new CFDataBuffer (address)) {
         if (buffer [1] == 30) { // AF_INET6
             int port = (buffer [2] << 8) + buffer [3];
             var bytes = new byte [16];
             Buffer.BlockCopy (buffer.Data, 8, bytes, 0, 16);
             return new IPEndPoint (new IPAddress (bytes), port);
         } else if (buffer [1] == 2) { // AF_INET
             int port = (buffer [2] << 8) + buffer [3];
             var bytes = new byte [4];
             Buffer.BlockCopy (buffer.Data, 4, bytes, 0, 4);
             return new IPEndPoint (new IPAddress (bytes), port);
         } else {
             throw new ArgumentException ();
         }
     }
 }
Example #2
0
		public void SetBody (byte[] buffer)
		{
			if (buffer == null)
				throw new ArgumentNullException ("buffer");
			
			using (var data = new CFDataBuffer (buffer))
				CFHTTPMessageSetBody (Handle, data.Handle);
		}
Example #3
0
 public void SendData(byte[] data, double timeout)
 {
     using (var buffer = new CFDataBuffer (data)) {
         var error = (CFSocketError) (long) CFSocketSendData (handle, IntPtr.Zero, buffer.Handle, timeout);
         if (error != CFSocketError.Success)
             throw new CFSocketException (error);
     }
 }