public virtual async Task <(int auxHandle, string ipAddress, int portNumber)> ConnectionRequest(AsyncWrappingCommonArgs async) { try { await Xdr.Write(IscCodes.op_connect_request, async).ConfigureAwait(false); await Xdr.Write(IscCodes.P_REQ_async, async).ConfigureAwait(false); await Xdr.Write(_handle, async).ConfigureAwait(false); await Xdr.Write(PartnerIdentification, async).ConfigureAwait(false); await Xdr.Flush(async).ConfigureAwait(false); await ReadOperation(async).ConfigureAwait(false); var auxHandle = await Xdr.ReadInt32(async).ConfigureAwait(false); var garbage1 = new byte[8]; await Xdr.ReadBytes(garbage1, 8, async).ConfigureAwait(false); var respLen = await Xdr.ReadInt32(async).ConfigureAwait(false); respLen += respLen % 4; var sin_family = new byte[2]; await Xdr.ReadBytes(sin_family, 2, async).ConfigureAwait(false); respLen -= 2; var sin_port = new byte[2]; await Xdr.ReadBytes(sin_port, 2, async).ConfigureAwait(false); var portNumber = (ushort)IPAddress.NetworkToHostOrder(BitConverter.ToInt16(sin_port, 0)); respLen -= 2; // * The address returned by the server may be incorrect if it is behind a NAT box // * so we must use the address that was used to connect the main socket, not the // * address reported by the server. var sin_addr = new byte[4]; await Xdr.ReadBytes(sin_addr, 4, async).ConfigureAwait(false); var ipAddress = _connection.IPAddress.ToString(); respLen -= 4; var garbage2 = new byte[respLen]; await Xdr.ReadBytes(garbage2, respLen, async).ConfigureAwait(false); await Xdr.ReadStatusVector(async).ConfigureAwait(false); return(auxHandle, ipAddress, portNumber); } catch (IOException ex) { throw IscException.ForIOException(ex); } }
public virtual void ConnectionRequest(out int auxHandle, out string ipAddress, out int portNumber) { try { Xdr.Write(IscCodes.op_connect_request); Xdr.Write(IscCodes.P_REQ_async); Xdr.Write(_handle); Xdr.Write(PartnerIdentification); Xdr.Flush(); ReadOperation(); auxHandle = Xdr.ReadInt32(); var garbage1 = new byte[8]; Xdr.ReadBytes(garbage1, 8); var respLen = Xdr.ReadInt32(); respLen += respLen % 4; var sin_family = new byte[2]; Xdr.ReadBytes(sin_family, 2); respLen -= 2; var sin_port = new byte[2]; Xdr.ReadBytes(sin_port, 2); portNumber = (ushort)IPAddress.NetworkToHostOrder(BitConverter.ToInt16(sin_port, 0)); respLen -= 2; // * The address returned by the server may be incorrect if it is behind a NAT box // * so we must use the address that was used to connect the main socket, not the // * address reported by the server. var sin_addr = new byte[4]; Xdr.ReadBytes(sin_addr, 4); //ipAddress = string.Format( // CultureInfo.InvariantCulture, // "{0}.{1}.{2}.{3}", // buffer[0], buffer[1], buffer[2], buffer[3]); ipAddress = _connection.IPAddress.ToString(); respLen -= 4; var garbage2 = new byte[respLen]; Xdr.ReadBytes(garbage2, respLen); Xdr.ReadStatusVector(); } catch (IOException ex) { throw IscException.ForErrorCode(IscCodes.isc_network_error, ex); } }
public virtual (int auxHandle, string ipAddress, int portNumber, int timeout) ConnectionRequest() { try { Xdr.Write(IscCodes.op_connect_request); Xdr.Write(IscCodes.P_REQ_async); Xdr.Write(_handle); Xdr.Write(PartnerIdentification); Xdr.Flush(); ReadOperation(); var auxHandle = Xdr.ReadInt32(); var garbage1 = new byte[8]; Xdr.ReadBytes(garbage1, 8); var respLen = Xdr.ReadInt32(); respLen += respLen % 4; var sin_family = new byte[2]; Xdr.ReadBytes(sin_family, 2); respLen -= 2; var sin_port = new byte[2]; Xdr.ReadBytes(sin_port, 2); var portNumber = (ushort)IPAddress.NetworkToHostOrder(BitConverter.ToInt16(sin_port, 0)); respLen -= 2; // * The address returned by the server may be incorrect if it is behind a NAT box // * so we must use the address that was used to connect the main socket, not the // * address reported by the server. var sin_addr = new byte[4]; Xdr.ReadBytes(sin_addr, 4); var ipAddress = _connection.IPAddress.ToString(); respLen -= 4; var garbage2 = new byte[respLen]; Xdr.ReadBytes(garbage2, respLen); Xdr.ReadStatusVector(); return(auxHandle, ipAddress, portNumber, _connection.Timeout); } catch (IOException ex) { throw IscException.ForIOException(ex); } }