コード例 #1
0
 internal static extern SocketError getsockopt(
     [In] SafeCloseSocket socketHandle,
     [In] SocketOptionLevel optionLevel,
     [In] SocketOptionName optionName,
     [Out] out Linger optionValue,
     [In, Out] ref int optionLength
     );
コード例 #2
0
 internal static extern SocketError setsockopt(
     [In] SafeCloseSocket socketHandle,
     [In] SocketOptionLevel optionLevel,
     [In] SocketOptionName optionName,
     [In] ref Linger linger,
     [In] int optionLength
     );
コード例 #3
0
ファイル: unsafenativemethods.cs プロジェクト: ydunk/masters
 internal static extern int setsockopt(
     [In] IntPtr socketHandle,
     [In] SocketOptionLevel optionLevel,
     [In] SocketOptionName optionName,
     [In] ref Linger linger,
     [In] int optionLength
     );
コード例 #4
0
ファイル: unsafenativemethods.cs プロジェクト: ydunk/masters
 internal static extern int getsockopt(
     [In] IntPtr socketHandle,
     [In] SocketOptionLevel optionLevel,
     [In] SocketOptionName optionName,
     [Out] out Linger optionValue,
     [In, Out] ref int optionLength
     );
コード例 #5
0
ファイル: SocketTest.cs プロジェクト: ZZHGit/mono
		public void SockOptLinger ()
		{
			WithSockets (UnixAddressFamily.AF_INET, UnixSocketType.SOCK_STREAM, UnixSocketProtocol.IPPROTO_TCP, (so1, so2) => {
				Linger linger = new Linger {
					l_onoff = 1,
					l_linger = 42,
				};
				// Set SO_LINGER
				if (Syscall.setsockopt (so1, UnixSocketProtocol.SOL_SOCKET, UnixSocketOptionName.SO_LINGER, linger) < 0)
					UnixMarshal.ThrowExceptionForLastError ();

				// Get and check SO_LINGER
				Linger value;
				if (Syscall.getsockopt (so1, UnixSocketProtocol.SOL_SOCKET, UnixSocketOptionName.SO_LINGER, out value) < 0)
					UnixMarshal.ThrowExceptionForLastError ();
				if (value.l_onoff == 0)
					Assert.Fail ("Linger not enabled");
				Assert.AreEqual (linger.l_linger, value.l_linger);
			});
		}
コード例 #6
0
ファイル: Socket.cs プロジェクト: REALTOBIZ/mono
        private LingerOption getLingerOpt() {
            Linger lngopt = new Linger();
            int optlen = 4;

            // This can throw ObjectDisposedException.
            SocketError errorCode = UnsafeNclNativeMethods.OSSOCK.getsockopt(
                m_Handle,
                SocketOptionLevel.Socket,
                SocketOptionName.Linger,
                out lngopt,
                ref optlen);

            GlobalLog.Print("Socket#" + ValidationHelper.HashString(this) + "::getLingerOpt() UnsafeNclNativeMethods.OSSOCK.getsockopt returns errorCode:" + errorCode);

            //
            // if the native call fails we'll throw a SocketException
            //
            if (errorCode==SocketError.SocketError) {
                //
                // update our internal state after this socket error and throw
                //
                SocketException socketException = new SocketException();
                UpdateStatusAfterSocketError(socketException);
                if(s_LoggingEnabled)Logging.Exception(Logging.Sockets, this, "getLingerOpt", socketException);
                throw socketException;
            }

            LingerOption lingerOption = new LingerOption(lngopt.OnOff!=0, (int)lngopt.Time);
            return lingerOption;
        }
コード例 #7
0
ファイル: Socket.cs プロジェクト: REALTOBIZ/mono
        private void setLingerOption(LingerOption lref) {
            Linger lngopt = new Linger();
            lngopt.OnOff = lref.Enabled ? (ushort)1 : (ushort)0;
            lngopt.Time = (ushort)lref.LingerTime;

            GlobalLog.Print("Socket#" + ValidationHelper.HashString(this) + "::setLingerOption(): lref:" + lref.ToString());

            // This can throw ObjectDisposedException.
            SocketError errorCode = UnsafeNclNativeMethods.OSSOCK.setsockopt(
                m_Handle,
                SocketOptionLevel.Socket,
                SocketOptionName.Linger,
                ref lngopt,
                4);

            GlobalLog.Print("Socket#" + ValidationHelper.HashString(this) + "::setLingerOption() UnsafeNclNativeMethods.OSSOCK.setsockopt returns errorCode:" + errorCode);

            //
            // if the native call fails we'll throw a SocketException
            //
            if (errorCode==SocketError.SocketError) {
                //
                // update our internal state after this socket error and throw
                //
                SocketException socketException = new SocketException();
                UpdateStatusAfterSocketError(socketException);
                if(s_LoggingEnabled)Logging.Exception(Logging.Sockets, this, "setLingerOption", socketException);
                throw socketException;
            }
        }
コード例 #8
0
ファイル: socket.cs プロジェクト: ArildF/masters
        private LingerOption getLingerOpt() {
            Linger lngopt = new Linger();
            int optlen = Linger.Size;

            int errorCode =
                UnsafeNclNativeMethods.OSSOCK.getsockopt(
                    m_Handle,
                    SocketOptionLevel.Socket,
                    SocketOptionName.Linger,
                    out lngopt,
                    ref optlen );

            //
            // if the native call fails we'll throw a SocketException
            //
            if (errorCode==SocketErrors.SocketError) {
                //
                // update our internal state after this socket error and throw
                //
                SocketException socketException = new SocketException();
                UpdateStatusAfterSocketError();
                throw socketException;
            }

            LingerOption lingerOption = new LingerOption(lngopt.OnOff!=0, (int)lngopt.Time);

            return lingerOption;
        }
コード例 #9
0
ファイル: socket.cs プロジェクト: ArildF/masters
        private void setLingerOption(LingerOption lref) {
            Linger lngopt = new Linger();
            lngopt.OnOff = lref.Enabled ? (short)1 : (short)0;
            lngopt.Time = (short)lref.LingerTime;

            GlobalLog.Print("Socket#" + ValidationHelper.HashString(this) + "::setLingerOption(): lref:" + lref.ToString());

            int errorCode =
                UnsafeNclNativeMethods.OSSOCK.setsockopt(
                    m_Handle,
                    SocketOptionLevel.Socket,
                    SocketOptionName.Linger,
                    ref lngopt,
                    Linger.Size);

            //
            // if the native call fails we'll throw a SocketException
            //
            if (errorCode==SocketErrors.SocketError) {
                //
                // update our internal state after this socket error and throw
                //
                SocketException socketException = new SocketException();
                UpdateStatusAfterSocketError();
                throw socketException;
            }
        }
コード例 #10
0
ファイル: Socket.cs プロジェクト: korifey/hackathon-Ideaphone
 private LingerOption getLingerOpt()
 {
     Linger optionValue = new Linger();
       int optionLength = 4;
       if (UnsafeNclNativeMethods.OSSOCK.getsockopt(this.m_Handle, SocketOptionLevel.Socket, SocketOptionName.Linger, out optionValue, out optionLength) != SocketError.SocketError)
     return new LingerOption((int) optionValue.OnOff != 0, (int) optionValue.Time);
       SocketException socketException = new SocketException();
       this.UpdateStatusAfterSocketError(socketException);
       if (Socket.s_LoggingEnabled)
     Logging.Exception(Logging.Sockets, (object) this, "getLingerOpt", (Exception) socketException);
       throw socketException;
 }
 internal static extern SocketError getsockopt([In] SafeCloseSocket socketHandle, [In] SocketOptionLevel optionLevel, [In] SocketOptionName optionName, out Linger optionValue, [In, Out] ref int optionLength);
コード例 #12
0
 private void setLingerOption(LingerOption lref)
 {
     Linger linger = new Linger {
         OnOff = lref.Enabled ? ((ushort) 1) : ((ushort) 0),
         Time = (ushort) lref.LingerTime
     };
     if (UnsafeNclNativeMethods.OSSOCK.setsockopt(this.m_Handle, SocketOptionLevel.Socket, SocketOptionName.Linger, ref linger, 4) == SocketError.SocketError)
     {
         SocketException socketException = new SocketException();
         this.UpdateStatusAfterSocketError(socketException);
         if (s_LoggingEnabled)
         {
             Logging.Exception(Logging.Sockets, this, "setLingerOption", socketException);
         }
         throw socketException;
     }
 }
コード例 #13
0
 private LingerOption getLingerOpt()
 {
     Linger optionValue = new Linger();
     int optionLength = 4;
     if (UnsafeNclNativeMethods.OSSOCK.getsockopt(this.m_Handle, SocketOptionLevel.Socket, SocketOptionName.Linger, out optionValue, ref optionLength) == SocketError.SocketError)
     {
         SocketException socketException = new SocketException();
         this.UpdateStatusAfterSocketError(socketException);
         if (s_LoggingEnabled)
         {
             Logging.Exception(Logging.Sockets, this, "getLingerOpt", socketException);
         }
         throw socketException;
     }
     return new LingerOption(optionValue.OnOff != 0, optionValue.Time);
 }