public void SetSocketOption(SocketOptionLevel optionLevel, UDTSocketOptionName optionName, object optionValue) { #if UDT_FULLTCP //_tcpSocket.SetSocketOption(optionLevel, optionName, optionValue); #else //---- UDT int size = -1; if (optionValue is int) { size = sizeof(int); } else if (optionValue is long) { size = sizeof(long); } else if (optionValue is LingerOption) { // If false it is the default behaviors. // If true the socket "close" method will wait that all the sending data have been send and // that he has receive the ack. The close method does not return until all the data is delivered // or until "time" (second linger option) has expired). /* * UDTLinger linger = new UDTLinger(); * linger.OnOff = ((LingerOption)optionValue).Enabled ? ((short)1) : ((short)0); * linger.Time = (short)((LingerOption)optionValue).LingerTime; * * size = Marshal.SizeOf(typeof(UDTLinger)); * * optionValue = linger;*/ return; } else { throw new NotImplementedException(); } try { API_Setsockopt(_handle, (int)optionLevel, optionName, ref optionValue, size); } catch (Exception e) { Console.Write(e.Message); } //API_Setsockopt(int handle, int level, UDTOption option, ref int optionValue /*const void* optval*/, int optlen); #endif }
public void SetSocketOption(SocketOptionLevel optionLevel, UDTSocketOptionName optionName, object optionValue) { #if UDT_FULLTCP //_tcpSocket.SetSocketOption(optionLevel, optionName, optionValue); #else //---- UDT int size = -1; if (optionValue is int) size = sizeof(int); else if (optionValue is long) size = sizeof(long); else if (optionValue is LingerOption) { // If false it is the default behaviors. // If true the socket "close" method will wait that all the sending data have been send and // that he has receive the ack. The close method does not return until all the data is delivered // or until "time" (second linger option) has expired). /* UDTLinger linger = new UDTLinger(); linger.OnOff = ((LingerOption)optionValue).Enabled ? ((short)1) : ((short)0); linger.Time = (short)((LingerOption)optionValue).LingerTime; size = Marshal.SizeOf(typeof(UDTLinger)); optionValue = linger;*/ return; } else throw new NotImplementedException(); try { API_Setsockopt(_handle, (int)optionLevel, optionName, ref optionValue, size); } catch (Exception e) { Console.Write(e.Message); } //API_Setsockopt(int handle, int level, UDTOption option, ref int optionValue /*const void* optval*/, int optlen); #endif }
public void SetSocketOption(SocketOptionLevel optionLevel, UDTSocketOptionName optionName, int optionValue) { SetSocketOption(optionLevel, optionName, (object)optionValue); }
private static extern int API_Getsockopt(int handle, int level, UDTSocketOptionName option, ref object optionValue, int optlen);
public void SetSocketOption(SocketOptionLevel optionLevel, UDTSocketOptionName optionName, int optionValue) { SetSocketOption(optionLevel, optionName, (object)optionValue); }
private static extern int API_Getsockopt(int handle, int level, UDTSocketOptionName option, ref object optionValue, int optlen);