本文整理汇总了C#中PipeTransmissionMode类的典型用法代码示例。如果您正苦于以下问题:C# PipeTransmissionMode类的具体用法?C# PipeTransmissionMode怎么用?C# PipeTransmissionMode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PipeTransmissionMode类属于命名空间,在下文中一共展示了PipeTransmissionMode类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Create
private void Create(string pipeName, PipeDirection direction, int maxNumberOfServerInstances,
PipeTransmissionMode transmissionMode, PipeOptions options, int inBufferSize, int outBufferSize,
HandleInheritability inheritability)
{
Debug.Assert(pipeName != null && pipeName.Length != 0, "fullPipeName is null or empty");
Debug.Assert(direction >= PipeDirection.In && direction <= PipeDirection.InOut, "invalid pipe direction");
Debug.Assert(inBufferSize >= 0, "inBufferSize is negative");
Debug.Assert(outBufferSize >= 0, "outBufferSize is negative");
Debug.Assert((maxNumberOfServerInstances >= 1) || (maxNumberOfServerInstances == MaxAllowedServerInstances), "maxNumberOfServerInstances is invalid");
Debug.Assert(transmissionMode >= PipeTransmissionMode.Byte && transmissionMode <= PipeTransmissionMode.Message, "transmissionMode is out of range");
if (transmissionMode == PipeTransmissionMode.Message)
{
throw new PlatformNotSupportedException(SR.PlatformNotSupported_MessageTransmissionMode);
}
// NOTE: We don't have a good way to enforce maxNumberOfServerInstances, and don't currently try.
// It's a Windows-specific concept.
_path = GetPipePath(".", pipeName);
_direction = direction;
_options = options;
_inBufferSize = inBufferSize;
_outBufferSize = outBufferSize;
_inheritability = inheritability;
}
开发者ID:ChuangYang,项目名称:corefx,代码行数:26,代码来源:NamedPipeServerStream.Unix.cs
示例2: NamedPipeServerStream
private NamedPipeServerStream(String pipeName, PipeDirection direction, int maxNumberOfServerInstances,
PipeTransmissionMode transmissionMode, PipeOptions options, int inBufferSize, int outBufferSize,
HandleInheritability inheritability)
: base(direction, transmissionMode, outBufferSize)
{
if (pipeName == null)
{
throw new ArgumentNullException("pipeName");
}
if (pipeName.Length == 0)
{
throw new ArgumentException(SR.Argument_NeedNonemptyPipeName);
}
if ((options & ~(PipeOptions.WriteThrough | PipeOptions.Asynchronous)) != 0)
{
throw new ArgumentOutOfRangeException("options", SR.ArgumentOutOfRange_OptionsInvalid);
}
if (inBufferSize < 0)
{
throw new ArgumentOutOfRangeException("inBufferSize", SR.ArgumentOutOfRange_NeedNonNegNum);
}
// win32 allows fixed values of 1-254 or 255 to mean max allowed by system. We expose 255 as -1 (unlimited)
// through the MaxAllowedServerInstances constant. This is consistent e.g. with -1 as infinite timeout, etc
if ((maxNumberOfServerInstances < 1 || maxNumberOfServerInstances > 254) && (maxNumberOfServerInstances != MaxAllowedServerInstances))
{
throw new ArgumentOutOfRangeException("maxNumberOfServerInstances", SR.ArgumentOutOfRange_MaxNumServerInstances);
}
if (inheritability < HandleInheritability.None || inheritability > HandleInheritability.Inheritable)
{
throw new ArgumentOutOfRangeException("inheritability", SR.ArgumentOutOfRange_HandleInheritabilityNoneOrInheritable);
}
Create(pipeName, direction, maxNumberOfServerInstances, transmissionMode,
options, inBufferSize, outBufferSize, inheritability);
}
开发者ID:niaomingjian,项目名称:corefx,代码行数:35,代码来源:NamedPipeServerStream.cs
示例3: Init
private void Init(PipeDirection direction, PipeTransmissionMode transmissionMode, int outBufferSize)
{
Debug.Assert(direction >= PipeDirection.In && direction <= PipeDirection.InOut, "invalid pipe direction");
Debug.Assert(transmissionMode >= PipeTransmissionMode.Byte && transmissionMode <= PipeTransmissionMode.Message, "transmissionMode is out of range");
Debug.Assert(outBufferSize >= 0, "outBufferSize is negative");
// always defaults to this until overridden
_readMode = transmissionMode;
_transmissionMode = transmissionMode;
_pipeDirection = direction;
if ((_pipeDirection & PipeDirection.In) != 0)
{
_canRead = true;
}
if ((_pipeDirection & PipeDirection.Out) != 0)
{
_canWrite = true;
}
_outBufferSize = outBufferSize;
// This should always default to true
_isMessageComplete = true;
_state = PipeState.WaitingToConnect;
_streamAsyncHelper = new StreamAsyncHelper(this);
}
开发者ID:jsalvadorp,项目名称:corefx,代码行数:29,代码来源:PipeStream.cs
示例4: NamedPipeServerStream
private NamedPipeServerStream(String pipeName, PipeDirection direction, int maxNumberOfServerInstances,
PipeTransmissionMode transmissionMode, PipeOptions options, int inBufferSize, int outBufferSize,
HandleInheritability inheritability)
: base(direction, transmissionMode, outBufferSize)
{
if (pipeName == null)
{
throw new ArgumentNullException("pipeName");
}
if (pipeName.Length == 0)
{
throw new ArgumentException(SR.Argument_NeedNonemptyPipeName);
}
if ((options & ~(PipeOptions.WriteThrough | PipeOptions.Asynchronous)) != 0)
{
throw new ArgumentOutOfRangeException("options", SR.ArgumentOutOfRange_OptionsInvalid);
}
if (inBufferSize < 0)
{
throw new ArgumentOutOfRangeException("inBufferSize", SR.ArgumentOutOfRange_NeedNonNegNum);
}
ValidateMaxNumberOfServerInstances(maxNumberOfServerInstances);
// inheritability will always be None since this private constructor is only called from other constructors from which
// inheritability is always set to None. Desktop has a public constructor to allow setting it to something else, but Core
// doesnt.
if (inheritability < HandleInheritability.None || inheritability > HandleInheritability.Inheritable)
{
throw new ArgumentOutOfRangeException("inheritability", SR.ArgumentOutOfRange_HandleInheritabilityNoneOrInheritable);
}
Create(pipeName, direction, maxNumberOfServerInstances, transmissionMode,
options, inBufferSize, outBufferSize, inheritability);
}
开发者ID:jmhardison,项目名称:corefx,代码行数:33,代码来源:NamedPipeServerStream.cs
示例5: Create
private void Create(string pipeName, PipeDirection direction, int maxNumberOfServerInstances,
PipeTransmissionMode transmissionMode, PipeOptions options, int inBufferSize, int outBufferSize,
HandleInheritability inheritability)
{
Debug.Assert(pipeName != null && pipeName.Length != 0, "fullPipeName is null or empty");
Debug.Assert(direction >= PipeDirection.In && direction <= PipeDirection.InOut, "invalid pipe direction");
Debug.Assert(inBufferSize >= 0, "inBufferSize is negative");
Debug.Assert(outBufferSize >= 0, "outBufferSize is negative");
Debug.Assert((maxNumberOfServerInstances >= 1) || (maxNumberOfServerInstances == MaxAllowedServerInstances), "maxNumberOfServerInstances is invalid");
Debug.Assert(transmissionMode >= PipeTransmissionMode.Byte && transmissionMode <= PipeTransmissionMode.Message, "transmissionMode is out of range");
if (transmissionMode == PipeTransmissionMode.Message)
{
throw new PlatformNotSupportedException();
}
// NOTE: We don't have a good way to enforce maxNumberOfServerInstances, and don't currently try.
// It's a Windows-specific concept.
// Make sure the FIFO exists, but don't open it until WaitForConnection is called.
_path = GetPipePath(".", pipeName);
while (true)
{
int result = Interop.libc.mkfifo(_path, (int)Interop.libc.Permissions.S_IRWXU);
if (result == 0)
{
// The FIFO was successfully created - note that although we create the FIFO here, we don't
// ever delete it. If we remove the FIFO we could invalidate other servers that also use it.
// See #2764 for further discussion.
break;
}
Interop.ErrorInfo errorInfo = Interop.Sys.GetLastErrorInfo();
if (errorInfo.Error == Interop.Error.EINTR)
{
// interrupted; try again
continue;
}
else if (errorInfo.Error == Interop.Error.EEXIST)
{
// FIFO already exists; nothing more to do
break;
}
else
{
// something else; fail
throw Interop.GetExceptionForIoErrno(errorInfo, _path);
}
}
// Store the rest of the creation arguments. They'll be used when we open the connection
// in WaitForConnection.
_direction = direction;
_options = options;
_inBufferSize = inBufferSize;
_outBufferSize = outBufferSize;
_inheritability = inheritability;
}
开发者ID:jmhardison,项目名称:corefx,代码行数:58,代码来源:NamedPipeServerStream.Unix.cs
示例6: Create
private void Create(string pipeName, PipeDirection direction, int maxNumberOfServerInstances,
PipeTransmissionMode transmissionMode, PipeOptions options, int inBufferSize, int outBufferSize,
HandleInheritability inheritability)
{
Debug.Assert(pipeName != null && pipeName.Length != 0, "fullPipeName is null or empty");
Debug.Assert(direction >= PipeDirection.In && direction <= PipeDirection.InOut, "invalid pipe direction");
Debug.Assert(inBufferSize >= 0, "inBufferSize is negative");
Debug.Assert(outBufferSize >= 0, "outBufferSize is negative");
Debug.Assert((maxNumberOfServerInstances >= 1 && maxNumberOfServerInstances <= 254) || (maxNumberOfServerInstances == MaxAllowedServerInstances), "maxNumberOfServerInstances is invalid");
Debug.Assert(transmissionMode >= PipeTransmissionMode.Byte && transmissionMode <= PipeTransmissionMode.Message, "transmissionMode is out of range");
throw NotImplemented.ByDesign; // TODO: Implement this
}
开发者ID:gitter-badger,项目名称:corefx,代码行数:13,代码来源:NamedPipeServerStream.Unix.cs
示例7: NamedPipeServerStream
public NamedPipeServerStream (string pipeName, PipeDirection direction, int maxNumberOfServerInstances, PipeTransmissionMode transmissionMode, PipeOptions options, int inBufferSize, int outBufferSize, PipeSecurity pipeSecurity, HandleInheritability inheritability, PipeAccessRights additionalAccessRights)
: base (direction, transmissionMode, outBufferSize)
{
if (pipeSecurity != null)
throw ThrowACLException ();
var rights = ToAccessRights (direction) | additionalAccessRights;
// FIXME: reject some rights declarations (for ACL).
if (IsWindows)
impl = new Win32NamedPipeServer (this, pipeName, maxNumberOfServerInstances, transmissionMode, rights, options, inBufferSize, outBufferSize, inheritability);
else
impl = new UnixNamedPipeServer (this, pipeName, maxNumberOfServerInstances, transmissionMode, rights, options, inBufferSize, outBufferSize, inheritability);
InitializeHandle (impl.Handle, false, (options & PipeOptions.Asynchronous) != PipeOptions.None);
}
开发者ID:runefs,项目名称:Marvin,代码行数:15,代码来源:NamedPipeServerStream.cs
示例8: PipeStream
protected PipeStream(PipeDirection direction, PipeTransmissionMode transmissionMode, int outBufferSize)
{
if ((direction < PipeDirection.In) || (direction > PipeDirection.InOut))
{
throw new ArgumentOutOfRangeException("direction", System.SR.GetString("ArgumentOutOfRange_DirectionModeInOutOrInOut"));
}
if ((transmissionMode < PipeTransmissionMode.Byte) || (transmissionMode > PipeTransmissionMode.Message))
{
throw new ArgumentOutOfRangeException("transmissionMode", System.SR.GetString("ArgumentOutOfRange_TransmissionModeByteOrMsg"));
}
if (outBufferSize < 0)
{
throw new ArgumentOutOfRangeException("outBufferSize", System.SR.GetString("ArgumentOutOfRange_NeedNonNegNum"));
}
this.Init(direction, transmissionMode, outBufferSize);
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:16,代码来源:PipeStream.cs
示例9: OverlappingPipeClientStream
/// <summary>
/// Initializes a new instance of the <see cref="OverlappingPipeClientStream"/> class.
/// </summary>
/// <param name="serverName">Name of the server.</param>
/// <param name="pipeName">Name of the pipe.</param>
/// <param name="transmissionMode"></param>
/// <param name="impersonationLevel">The impersonation level.</param>
/// <param name="inheritability">The inheritability.</param>
public OverlappingPipeClientStream(
[NotNull] string serverName,
[NotNull] string pipeName,
PipeTransmissionMode transmissionMode,
TokenImpersonationLevel impersonationLevel = TokenImpersonationLevel.None,
HandleInheritability inheritability = HandleInheritability.None)
: base(new NamedPipeClientStream(
serverName,
pipeName,
PipeDirection.InOut,
PipeOptions.Asynchronous,
impersonationLevel,
inheritability))
{
Debug.Assert(Stream != null);
ReadMode = transmissionMode;
}
开发者ID:webappsuk,项目名称:CoreLibraries,代码行数:25,代码来源:OverlappingPipeClientStream.cs
示例10: PipeStream
protected PipeStream(PipeDirection direction, PipeTransmissionMode transmissionMode, int outBufferSize)
{
if (direction < PipeDirection.In || direction > PipeDirection.InOut)
{
throw new ArgumentOutOfRangeException("direction", SR.ArgumentOutOfRange_DirectionModeInOutOrInOut);
}
if (transmissionMode < PipeTransmissionMode.Byte || transmissionMode > PipeTransmissionMode.Message)
{
throw new ArgumentOutOfRangeException("transmissionMode", SR.ArgumentOutOfRange_TransmissionModeByteOrMsg);
}
if (outBufferSize < 0)
{
throw new ArgumentOutOfRangeException("outBufferSize", SR.ArgumentOutOfRange_NeedNonNegNum);
}
Init(direction, transmissionMode, outBufferSize);
}
开发者ID:jsalvadorp,项目名称:corefx,代码行数:17,代码来源:PipeStream.cs
示例11: Create
private void Create(string pipeName, PipeDirection direction, int maxNumberOfServerInstances,
PipeTransmissionMode transmissionMode, PipeOptions options, int inBufferSize, int outBufferSize,
HandleInheritability inheritability)
{
Debug.Assert(pipeName != null && pipeName.Length != 0, "fullPipeName is null or empty");
Debug.Assert(direction >= PipeDirection.In && direction <= PipeDirection.InOut, "invalid pipe direction");
Debug.Assert(inBufferSize >= 0, "inBufferSize is negative");
Debug.Assert(outBufferSize >= 0, "outBufferSize is negative");
Debug.Assert((maxNumberOfServerInstances >= 1 && maxNumberOfServerInstances <= 254) || (maxNumberOfServerInstances == MaxAllowedServerInstances), "maxNumberOfServerInstances is invalid");
Debug.Assert(transmissionMode >= PipeTransmissionMode.Byte && transmissionMode <= PipeTransmissionMode.Message, "transmissionMode is out of range");
string fullPipeName = Path.GetFullPath(@"\\.\pipe\" + pipeName);
// Make sure the pipe name isn't one of our reserved names for anonymous pipes.
if (String.Equals(fullPipeName, @"\\.\pipe\anonymous", StringComparison.OrdinalIgnoreCase))
{
throw new ArgumentOutOfRangeException("pipeName", SR.ArgumentOutOfRange_AnonymousReserved);
}
int openMode = ((int)direction) |
(maxNumberOfServerInstances == 1 ? Interop.mincore.FileOperations.FILE_FLAG_FIRST_PIPE_INSTANCE : 0) |
(int)options;
// We automatically set the ReadMode to match the TransmissionMode.
int pipeModes = (int)transmissionMode << 2 | (int)transmissionMode << 1;
// Convert -1 to 255 to match win32 (we asserted that it is between -1 and 254).
if (maxNumberOfServerInstances == MaxAllowedServerInstances)
{
maxNumberOfServerInstances = 255;
}
Interop.mincore.SECURITY_ATTRIBUTES secAttrs = PipeStream.GetSecAttrs(inheritability);
SafePipeHandle handle = Interop.mincore.CreateNamedPipe(fullPipeName, openMode, pipeModes,
maxNumberOfServerInstances, outBufferSize, inBufferSize, 0, ref secAttrs);
if (handle.IsInvalid)
{
throw Win32Marshal.GetExceptionForLastWin32Error();
}
InitializeHandle(handle, false, (options & PipeOptions.Asynchronous) != 0);
}
开发者ID:jsalvadorp,项目名称:corefx,代码行数:44,代码来源:NamedPipeServerStream.Windows.cs
示例12: NamedPipeServerStream
private NamedPipeServerStream(String pipeName, PipeDirection direction, int maxNumberOfServerInstances,
PipeTransmissionMode transmissionMode, PipeOptions options, int inBufferSize, int outBufferSize,
HandleInheritability inheritability)
: base(direction, transmissionMode, outBufferSize)
{
if (pipeName == null)
{
throw new ArgumentNullException(nameof(pipeName));
}
if (pipeName.Length == 0)
{
throw new ArgumentException(SR.Argument_NeedNonemptyPipeName);
}
if ((options & ~(PipeOptions.WriteThrough | PipeOptions.Asynchronous)) != 0)
{
throw new ArgumentOutOfRangeException(nameof(options), SR.ArgumentOutOfRange_OptionsInvalid);
}
if (inBufferSize < 0)
{
throw new ArgumentOutOfRangeException(nameof(inBufferSize), SR.ArgumentOutOfRange_NeedNonNegNum);
}
if ((maxNumberOfServerInstances < 1 || maxNumberOfServerInstances > 254) && (maxNumberOfServerInstances != MaxAllowedServerInstances))
{
// win32 allows fixed values of 1-254 or 255 to mean max allowed by system. We expose 255 as -1 (unlimited)
// through the MaxAllowedServerInstances constant. This is consistent e.g. with -1 as infinite timeout, etc.
// We do this check for consistency on Unix, even though maxNumberOfServerInstances is otherwise ignored.
throw new ArgumentOutOfRangeException(nameof(maxNumberOfServerInstances), SR.ArgumentOutOfRange_MaxNumServerInstances);
}
// inheritability will always be None since this private constructor is only called from other constructors from which
// inheritability is always set to None. Desktop has a public constructor to allow setting it to something else, but Core
// doesn't.
if (inheritability < HandleInheritability.None || inheritability > HandleInheritability.Inheritable)
{
throw new ArgumentOutOfRangeException(nameof(inheritability), SR.ArgumentOutOfRange_HandleInheritabilityNoneOrInheritable);
}
Create(pipeName, direction, maxNumberOfServerInstances, transmissionMode,
options, inBufferSize, outBufferSize, inheritability);
}
开发者ID:dotnet,项目名称:corefx,代码行数:40,代码来源:NamedPipeServerStream.cs
示例13: ValidateOptions
protected void ValidateOptions (PipeOptions options, PipeTransmissionMode mode)
{
if ((options & PipeOptions.WriteThrough) != 0)
throw new NotImplementedException ("WriteThrough is not supported");
if ((mode & PipeTransmissionMode.Message) != 0)
throw new NotImplementedException ("Message transmission mode is not supported");
if ((options & PipeOptions.Asynchronous) != 0) // FIXME: use O_NONBLOCK?
throw new NotImplementedException ("Asynchronous pipe mode is not supported");
}
开发者ID:nlhepler,项目名称:mono,代码行数:10,代码来源:PipeUnix.cs
示例14: PipeStream
protected PipeStream(PipeDirection direction, PipeTransmissionMode transmissionMode, int outBufferSize)
{
}
开发者ID:asvishnyakov,项目名称:CodeContracts,代码行数:3,代码来源:System.IO.Pipes.PipeStream.cs
示例15: Mode
public NamedPipeChannelConfigurator Mode( PipeTransmissionMode mode )
{
Definition.Mode = mode;
return this;
}
开发者ID:cmgator,项目名称:Symbiote,代码行数:5,代码来源:NamedPipeChannelConfigurator.cs
示例16: Create
private void Create(String fullPipeName, PipeDirection direction, int maxNumberOfServerInstances,
PipeTransmissionMode transmissionMode, PipeOptions options, int inBufferSize, int outBufferSize,
PipeAccessRights rights, UnsafeNativeMethods.SECURITY_ATTRIBUTES secAttrs) {
Debug.Assert(fullPipeName != null && fullPipeName.Length != 0, "fullPipeName is null or empty");
Debug.Assert(direction >= PipeDirection.In && direction <= PipeDirection.InOut, "invalid pipe direction");
Debug.Assert(inBufferSize >= 0, "inBufferSize is negative");
Debug.Assert(outBufferSize >= 0, "outBufferSize is negative");
Debug.Assert((maxNumberOfServerInstances >= 1 && maxNumberOfServerInstances <= 254) || (maxNumberOfServerInstances == MaxAllowedServerInstances), "maxNumberOfServerInstances is invalid");
Debug.Assert(transmissionMode >= PipeTransmissionMode.Byte && transmissionMode <= PipeTransmissionMode.Message, "transmissionMode is out of range");
int openMode = ((int)direction) |
(maxNumberOfServerInstances == 1 ? UnsafeNativeMethods.FILE_FLAG_FIRST_PIPE_INSTANCE : 0) |
(int)options |
(int)rights;
// We automatically set the ReadMode to match the TransmissionMode.
int pipeModes = (int)transmissionMode << 2 | (int)transmissionMode << 1;
// Convert -1 to 255 to match win32 (we asserted that it is between -1 and 254).
if (maxNumberOfServerInstances == MaxAllowedServerInstances) {
maxNumberOfServerInstances = 255;
}
SafePipeHandle handle = UnsafeNativeMethods.CreateNamedPipe(fullPipeName, openMode, pipeModes,
maxNumberOfServerInstances, outBufferSize, inBufferSize, 0, secAttrs);
if (handle.IsInvalid) {
__Error.WinIOError(Marshal.GetLastWin32Error(), String.Empty);
}
InitializeHandle(handle, false, (options & PipeOptions.Asynchronous) != 0);
}
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:32,代码来源:Pipe.cs
示例17: NamedPipeServerStream
public NamedPipeServerStream(String pipeName, PipeDirection direction, int maxNumberOfServerInstances,
PipeTransmissionMode transmissionMode, PipeOptions options, int inBufferSize, int outBufferSize,
PipeSecurity pipeSecurity, HandleInheritability inheritability, PipeAccessRights additionalAccessRights)
: base(direction, transmissionMode, outBufferSize) {
if (pipeName == null) {
throw new ArgumentNullException("pipeName");
}
if (pipeName.Length == 0) {
throw new ArgumentException(SR.GetString(SR.Argument_NeedNonemptyPipeName));
}
if ((options & ~(PipeOptions.WriteThrough | PipeOptions.Asynchronous)) != 0) {
throw new ArgumentOutOfRangeException("options", SR.GetString(SR.ArgumentOutOfRange_OptionsInvalid));
}
if (inBufferSize < 0) {
throw new ArgumentOutOfRangeException("inBufferSize", SR.GetString(SR.ArgumentOutOfRange_NeedNonNegNum));
}
// win32 allows fixed values of 1-254 or 255 to mean max allowed by system. We expose 255 as -1 (unlimited)
// through the MaxAllowedServerInstances constant. This is consistent e.g. with -1 as infinite timeout, etc
if ((maxNumberOfServerInstances < 1 || maxNumberOfServerInstances > 254) && (maxNumberOfServerInstances != MaxAllowedServerInstances)) {
throw new ArgumentOutOfRangeException("maxNumberOfServerInstances", SR.GetString(SR.ArgumentOutOfRange_MaxNumServerInstances));
}
if (inheritability < HandleInheritability.None || inheritability > HandleInheritability.Inheritable) {
throw new ArgumentOutOfRangeException("inheritability", SR.GetString(SR.ArgumentOutOfRange_HandleInheritabilityNoneOrInheritable));
}
// ChangePermissions, TakeOwnership, and AccessSystemSecurity are only legal values user may provide;
// internally this is set to 0 if not provided. This handles both cases.
if ((additionalAccessRights & ~(PipeAccessRights.ChangePermissions | PipeAccessRights.TakeOwnership |
PipeAccessRights.AccessSystemSecurity)) != 0) {
throw new ArgumentOutOfRangeException("additionalAccessRights", SR.GetString(SR.ArgumentOutOfRange_AdditionalAccessLimited));
}
// Named Pipe Servers require Windows NT
if (Environment.OSVersion.Platform == PlatformID.Win32Windows) {
throw new PlatformNotSupportedException(SR.GetString(SR.PlatformNotSupported_NamedPipeServers));
}
string normalizedPipePath = Path.GetFullPath(@"\\.\pipe\" + pipeName);
// Make sure the pipe name isn't one of our reserved names for anonymous pipes.
if (String.Compare(normalizedPipePath, @"\\.\pipe\anonymous", StringComparison.OrdinalIgnoreCase) == 0) {
throw new ArgumentOutOfRangeException("pipeName", SR.GetString(SR.ArgumentOutOfRange_AnonymousReserved));
}
Object pinningHandle = null;
UnsafeNativeMethods.SECURITY_ATTRIBUTES secAttrs = PipeStream.GetSecAttrs(inheritability, pipeSecurity, out pinningHandle);
try {
Create(normalizedPipePath, direction, maxNumberOfServerInstances, transmissionMode,
options, inBufferSize, outBufferSize, additionalAccessRights, secAttrs);
}
finally {
if (pinningHandle != null) {
GCHandle pinHandle = (GCHandle)pinningHandle;
pinHandle.Free();
}
}
}
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:57,代码来源:Pipe.cs
示例18: Win32NamedPipeServer
// .ctor without handle - create new
public Win32NamedPipeServer (NamedPipeServerStream owner, string pipeName, int maxNumberOfServerInstances, PipeTransmissionMode transmissionMode, PipeAccessRights rights, PipeOptions options, int inBufferSize, int outBufferSize, HandleInheritability inheritability)
{
string name = String.Format ("\\\\.\\pipe\\{0}", pipeName);
uint openMode = 0;
if ((rights & PipeAccessRights.ReadData) != 0)
openMode |= 1;
if ((rights & PipeAccessRights.WriteData) != 0)
openMode |= 2;
if ((options & PipeOptions.WriteThrough) != 0)
openMode |= 0x80000000;
int pipeMode = 0;
if ((owner.TransmissionMode & PipeTransmissionMode.Message) != 0)
pipeMode |= 4;
//if ((readTransmissionMode & PipeTransmissionMode.Message) != 0)
// pipeMode |= 2;
if ((options & PipeOptions.Asynchronous) != 0)
pipeMode |= 1;
// FIXME: is nDefaultTimeout = 0 ok?
var att = new SecurityAttributesHack (inheritability == HandleInheritability.Inheritable);
var ret = Win32Marshal.CreateNamedPipe (name, openMode, pipeMode, maxNumberOfServerInstances, outBufferSize, inBufferSize, 0, ref att, IntPtr.Zero);
if (ret == new IntPtr (-1L))
throw new Win32Exception (Marshal.GetLastWin32Error ());
handle = new SafePipeHandle (ret, true);
}
开发者ID:runefs,项目名称:Marvin,代码行数:27,代码来源:PipeWin32.cs
示例19: UnixNamedPipeServer
// .ctor without handle - create new
public UnixNamedPipeServer (NamedPipeServerStream owner, string pipeName, int maxNumberOfServerInstances,
PipeTransmissionMode transmissionMode, PipeAccessRights rights, PipeOptions options,
int inBufferSize, int outBufferSize, HandleInheritability inheritability)
{
string name = Path.Combine ("/var/tmp/", pipeName);
EnsureTargetFile (name);
RightsToAccess (rights);
ValidateOptions (options, owner.TransmissionMode);
// FIXME: maxNumberOfServerInstances, modes, sizes, handle inheritability
var fs = new FileStream (name, FileMode.Open, RightsToFileAccess (rights), FileShare.ReadWrite);
handle = new SafePipeHandle (fs.Handle, false);
owner.Stream = fs;
should_close_handle = true;
}
开发者ID:nlhepler,项目名称:mono,代码行数:19,代码来源:PipeUnix.cs
示例20: UpdateReadMode
private void UpdateReadMode() {
int flags;
if (!UnsafeNativeMethods.GetNamedPipeHandleState(SafePipeHandle, out flags, UnsafeNativeMethods.NULL, UnsafeNativeMethods.NULL,
UnsafeNativeMethods.NULL, UnsafeNativeMethods.NULL, 0)) {
WinIOError(Marshal.GetLastWin32Error());
}
if ((flags & UnsafeNativeMethods.PIPE_READMODE_MESSAGE) != 0) {
m_readMode = PipeTransmissionMode.Message;
}
else {
m_readMode = PipeTransmissionMode.Byte;
}
}
开发者ID:uQr,项目名称:referencesource,代码行数:14,代码来源:PipeStream.cs
注:本文中的PipeTransmissionMode类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论