本文整理汇总了C#中System.Net.Sockets.SafeSocketHandle类的典型用法代码示例。如果您正苦于以下问题:C# SafeSocketHandle类的具体用法?C# SafeSocketHandle怎么用?C# SafeSocketHandle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SafeSocketHandle类属于System.Net.Sockets命名空间,在下文中一共展示了SafeSocketHandle类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Send_internal
static int Send_internal (SafeSocketHandle safeHandle, byte[] buf, int offset, int count, SocketFlags flags, out int error, bool blocking)
{
try {
safeHandle.RegisterForBlockingSyscall ();
return Send_internal (safeHandle.DangerousGetHandle (), buf, offset, count, flags, out error, blocking);
} finally {
safeHandle.UnRegisterForBlockingSyscall ();
}
}
开发者ID:grendello,项目名称:mono,代码行数:9,代码来源:Socket.cs
示例2: Available_internal
static int Available_internal (SafeSocketHandle safeHandle, out int error)
{
bool release = false;
try {
safeHandle.DangerousAddRef (ref release);
return Available_internal (safeHandle.DangerousGetHandle (), out error);
} finally {
if (release)
safeHandle.DangerousRelease ();
}
}
开发者ID:Profit0004,项目名称:mono,代码行数:11,代码来源:Socket.cs
示例3: RemoteEndPoint_internal
static SocketAddress RemoteEndPoint_internal (SafeSocketHandle safeHandle, int family, out int error)
{
bool release = false;
try {
safeHandle.DangerousAddRef (ref release);
return RemoteEndPoint_internal (safeHandle.DangerousGetHandle (), family, out error);
} finally {
if (release)
safeHandle.DangerousRelease ();
}
}
开发者ID:Profit0004,项目名称:mono,代码行数:11,代码来源:Socket.cs
示例4: IOControl_internal
static int IOControl_internal (SafeSocketHandle safeHandle, int ioctl_code, byte [] input, byte [] output, out int error)
{
bool release = false;
try {
safeHandle.DangerousAddRef (ref release);
return IOControl_internal (safeHandle.DangerousGetHandle (), ioctl_code, input, output, out error);
} finally {
if (release)
safeHandle.DangerousRelease ();
}
}
开发者ID:Profit0004,项目名称:mono,代码行数:11,代码来源:Socket.cs
示例5: Socket
/* private constructor used by Accept, which already has a socket handle to use */
internal Socket(AddressFamily family, SocketType type, ProtocolType proto, SafeSocketHandle safe_handle)
{
this.address_family = family;
this.socket_type = type;
this.protocol_type = proto;
this.safe_handle = safe_handle;
this.is_connected = true;
}
开发者ID:Profit0004,项目名称:mono,代码行数:10,代码来源:Socket.cs
示例6: SendTo_internal
static int SendTo_internal (SafeSocketHandle safeHandle, byte[] buffer, int offset, int count, SocketFlags flags, SocketAddress sa, out int error)
{
try {
safeHandle.RegisterForBlockingSyscall ();
return SendTo_internal (safeHandle.DangerousGetHandle (), buffer, offset, count, flags, sa, out error);
} finally {
safeHandle.UnRegisterForBlockingSyscall ();
}
}
开发者ID:Profit0004,项目名称:mono,代码行数:9,代码来源:Socket.cs
示例7: RecvFrom_internal
private static int RecvFrom_internal (SafeSocketHandle safeHandle,
byte[] buffer,
int offset,
int count,
SocketFlags flags,
ref SocketAddress sockaddr,
out int error)
{
try {
safeHandle.RegisterForBlockingSyscall ();
return RecvFrom_internal (safeHandle.DangerousGetHandle (), buffer, offset, count, flags, ref sockaddr, out error);
} finally {
safeHandle.UnRegisterForBlockingSyscall ();
}
}
开发者ID:jamescourtney,项目名称:mono,代码行数:15,代码来源:Socket.cs
示例8: Socket
public Socket (SocketInformation socketInformation)
{
var options = socketInformation.Options;
islistening = (options & SocketInformationOptions.Listening) != 0;
connected = (options & SocketInformationOptions.Connected) != 0;
blocking = (options & SocketInformationOptions.NonBlocking) == 0;
useoverlappedIO = (options & SocketInformationOptions.UseOnlyOverlappedIO) != 0;
var result = Mono.DataConverter.Unpack ("iiiil", socketInformation.ProtocolInformation, 0);
address_family = (AddressFamily) (int) result [0];
socket_type = (SocketType) (int) result [1];
protocol_type = (ProtocolType) (int) result [2];
isbound = (ProtocolType) (int) result [3] != 0;
socket = new SafeSocketHandle ((IntPtr) (long) result [4], true);
SocketDefaults ();
}
开发者ID:jamescourtney,项目名称:mono,代码行数:17,代码来源:Socket.cs
示例9: GetSocketOption_arr_internal
private static void GetSocketOption_arr_internal (SafeSocketHandle safeHandle,
SocketOptionLevel level, SocketOptionName name, ref byte[] byte_val,
out int error)
{
bool release = false;
try {
safeHandle.DangerousAddRef (ref release);
GetSocketOption_arr_internal (safeHandle.DangerousGetHandle (), level, name, ref byte_val, out error);
} finally {
if (release)
safeHandle.DangerousRelease ();
}
}
开发者ID:jamescourtney,项目名称:mono,代码行数:13,代码来源:Socket.cs
示例10: BeginConnect
IAsyncResult BeginConnect(EndPoint end_point, AsyncCallback callback, object state)
{
if (disposed && closed)
throw new ObjectDisposedException (GetType ().ToString ());
if (end_point == null)
throw new ArgumentNullException ("end_point");
SocketAsyncResult req = new SocketAsyncResult (this, state, callback, SocketOperation.Connect);
req.EndPoint = end_point;
// Bug #75154: Connect() should not succeed for .Any addresses.
if (end_point is IPEndPoint) {
IPEndPoint ep = (IPEndPoint) end_point;
if (ep.Address.Equals (IPAddress.Any) || ep.Address.Equals (IPAddress.IPv6Any)) {
req.Complete (new SocketException ((int) SocketError.AddressNotAvailable), true);
return req;
}
}
int error = 0;
if (connect_in_progress) {
// This could happen when multiple IPs are used
// Calling connect() again will reset the connection attempt and cause
// an error. Better to just close the socket and move on.
connect_in_progress = false;
socket.Dispose ();
var handle = Socket_internal (address_family, socket_type, protocol_type, out error);
socket = new SafeSocketHandle (handle, true);
if (error != 0)
throw new SocketException (error);
}
bool blk = blocking;
if (blk)
Blocking = false;
SocketAddress serial = end_point.Serialize ();
Connect_internal (socket, serial, out error);
if (blk)
Blocking = true;
if (error == 0) {
// succeeded synch
connected = true;
isbound = true;
req.Complete (true);
return req;
}
if (error != (int) SocketError.InProgress && error != (int) SocketError.WouldBlock) {
// error synch
connected = false;
isbound = false;
req.Complete (new SocketException (error), true);
return req;
}
// continue asynch
connected = false;
isbound = false;
connect_in_progress = true;
socket_pool_queue (Worker.Dispatcher, req);
return req;
}
开发者ID:jamescourtney,项目名称:mono,代码行数:62,代码来源:Socket_2_1.cs
示例11: EnsureSocket
//internal Socket (AddressFamily family, SocketType type, ProtocolType proto, IntPtr sock)
bool EnsureSocket ()
{
lock (_lock) {
if (nl_sock != null)
return true;
IntPtr fd = CreateNLSocket ();
if (fd.ToInt64 () == -1)
return false;
var safeHandle = new SafeSocketHandle (fd, true);
nl_sock = new Socket (0, SocketType.Raw, ProtocolType.Udp, safeHandle);
nl_args = new SocketAsyncEventArgs ();
nl_args.SetBuffer (new byte [8192], 0, 8192);
nl_args.Completed += OnDataAvailable;
nl_sock.ReceiveAsync (nl_args);
}
return true;
}
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:21,代码来源:NetworkChange.cs
示例12: Socket
public Socket(AddressFamily addressFamily, SocketType socketType, ProtocolType protocolType)
{
this.address_family = addressFamily;
this.socket_type = socketType;
this.protocol_type = protocolType;
int error;
this.safe_handle = new SafeSocketHandle (Socket_internal (addressFamily, socketType, protocolType, out error), true);
if (error != 0)
throw new SocketException (error);
SocketDefaults ();
}
开发者ID:ArsenShnurkov,项目名称:mono,代码行数:14,代码来源:Socket.cs
示例13: Receive_internal
static int Receive_internal (SafeSocketHandle safeHandle, WSABUF[] bufarray, SocketFlags flags, out int error)
{
try {
safeHandle.RegisterForBlockingSyscall ();
return Receive_internal (safeHandle.DangerousGetHandle (), bufarray, flags, out error);
} finally {
safeHandle.UnRegisterForBlockingSyscall ();
}
}
开发者ID:Profit0004,项目名称:mono,代码行数:9,代码来源:Socket.cs
示例14: Accept_internal
static SafeSocketHandle Accept_internal (SafeSocketHandle safeHandle, out int error, bool blocking)
{
try {
safeHandle.RegisterForBlockingSyscall ();
var ret = Accept_internal (safeHandle.DangerousGetHandle (), out error, blocking);
return new SafeSocketHandle (ret, true);
} finally {
safeHandle.UnRegisterForBlockingSyscall ();
}
}
开发者ID:Profit0004,项目名称:mono,代码行数:10,代码来源:Socket.cs
示例15: Bind_internal
private static void Bind_internal (SafeSocketHandle safeHandle, SocketAddress sa, out int error)
{
bool release = false;
try {
safeHandle.DangerousAddRef (ref release);
Bind_internal (safeHandle.DangerousGetHandle (), sa, out error);
} finally {
if (release)
safeHandle.DangerousRelease ();
}
}
开发者ID:Profit0004,项目名称:mono,代码行数:11,代码来源:Socket.cs
示例16: Send_internal
static int Send_internal (SafeSocketHandle safeHandle, WSABUF[] bufarray, SocketFlags flags, out int error)
{
bool release = false;
try {
safeHandle.DangerousAddRef (ref release);
return Send_internal (safeHandle.DangerousGetHandle (), bufarray, flags, out error);
} finally {
if (release)
safeHandle.DangerousRelease ();
}
}
开发者ID:Profit0004,项目名称:mono,代码行数:11,代码来源:Socket.cs
示例17: Listen_internal
static void Listen_internal (SafeSocketHandle safeHandle, int backlog, out int error)
{
bool release = false;
try {
safeHandle.DangerousAddRef (ref release);
Listen_internal (safeHandle.DangerousGetHandle (), backlog, out error);
} finally {
if (release)
safeHandle.DangerousRelease ();
}
}
开发者ID:Profit0004,项目名称:mono,代码行数:11,代码来源:Socket.cs
示例18: SendFile_internal
static bool SendFile_internal (SafeSocketHandle safeHandle, string filename, byte [] pre_buffer, byte [] post_buffer, TransmitFileOptions flags)
{
try {
safeHandle.RegisterForBlockingSyscall ();
return SendFile_internal (safeHandle.DangerousGetHandle (), filename, pre_buffer, post_buffer, flags);
} finally {
safeHandle.UnRegisterForBlockingSyscall ();
}
}
开发者ID:Profit0004,项目名称:mono,代码行数:9,代码来源:Socket.cs
示例19: BeginConnect
public IAsyncResult BeginConnect (EndPoint end_point, AsyncCallback callback, object state)
{
ThrowIfDisposedAndClosed ();
if (end_point == null)
throw new ArgumentNullException ("end_point");
SocketAsyncResult sockares = new SocketAsyncResult (this, callback, state, SocketOperation.Connect) {
EndPoint = end_point,
};
// Bug #75154: Connect() should not succeed for .Any addresses.
if (end_point is IPEndPoint) {
IPEndPoint ep = (IPEndPoint) end_point;
if (ep.Address.Equals (IPAddress.Any) || ep.Address.Equals (IPAddress.IPv6Any)) {
sockares.Complete (new SocketException ((int) SocketError.AddressNotAvailable), true);
return sockares;
}
}
int error = 0;
if (connect_in_progress) {
// This could happen when multiple IPs are used
// Calling connect() again will reset the connection attempt and cause
// an error. Better to just close the socket and move on.
connect_in_progress = false;
safe_handle.Dispose ();
safe_handle = new SafeSocketHandle (Socket_internal (address_family, socket_type, protocol_type, out error), true);
if (error != 0)
throw new SocketException (error);
}
bool blk = is_blocking;
if (blk)
Blocking = false;
Connect_internal (safe_handle, end_point.Serialize (), out error);
if (blk)
Blocking = true;
if (error == 0) {
// succeeded synch
is_connected = true;
is_bound = true;
sockares.Complete (true);
return sockares;
}
if (error != (int) SocketError.InProgress && error != (int) SocketError.WouldBlock) {
// error synch
is_connected = false;
is_bound = false;
sockares.Complete (new SocketException (error), true);
return sockares;
}
// continue asynch
is_connected = false;
is_bound = false;
connect_in_progress = true;
IOSelector.Add (sockares.Handle, new IOSelectorJob (IOOperation.Write, BeginConnectCallback, sockares));
return sockares;
}
开发者ID:Profit0004,项目名称:mono,代码行数:65,代码来源:Socket.cs
示例20: SetSocketOption_internal
static void SetSocketOption_internal (SafeSocketHandle safeHandle, SocketOptionLevel level, SocketOptionName name, object obj_val, byte [] byte_val, int int_val, out int error)
{
bool release = false;
try {
safeHandle.DangerousAddRef (ref release);
SetSocketOption_internal (safeHandle.DangerousGetHandle (), level, name, obj_val, byte_val, int_val, out error);
} finally {
if (release)
safeHandle.DangerousRelease ();
}
}
开发者ID:Profit0004,项目名称:mono,代码行数:11,代码来源:Socket.cs
注:本文中的System.Net.Sockets.SafeSocketHandle类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论