Class Socket
- Namespace
- Gio
- Assembly
- Gio-2.0.dll
public class Socket : Object, DatagramBased, Initable, NativeObject, IDisposable, GTypeProvider, InstanceFactory
- Inheritance
-
Socket
- Implements
- Inherited Members
Constructors
Socket(params ConstructArgument[])
[Obsolete("Regular C# constructors on native classes will be removed in a future version. Please see the linked documentation for more details. It contains scenarios and possible solutions to prepare for the upcoming changes.", DiagnosticId = "GirCore1007", UrlFormat = "https://gircore.github.io/docs/integration/diagnostic/1007.html")]
public Socket(params ConstructArgument[] constructArguments)
Parameters
constructArgumentsConstructArgument[]
Socket(CreationData)
[Obsolete("This constructor is a workaround to keep legacy APIs alive. Do not use it.")]
protected Socket(CreationData data)
Parameters
dataCreationData
Socket(SocketHandle)
protected Socket(SocketHandle handle)
Parameters
handleSocketHandle
Fields
BlockingPropertyDefinition
public static readonly Property<bool, Socket> BlockingPropertyDefinition
Field Value
BroadcastPropertyDefinition
public static readonly Property<bool, Socket> BroadcastPropertyDefinition
Field Value
FamilyPropertyDefinition
public static readonly Property<SocketFamily, Socket> FamilyPropertyDefinition
Field Value
FdPropertyDefinition
public static readonly Property<int, Socket> FdPropertyDefinition
Field Value
KeepalivePropertyDefinition
public static readonly Property<bool, Socket> KeepalivePropertyDefinition
Field Value
ListenBacklogPropertyDefinition
public static readonly Property<int, Socket> ListenBacklogPropertyDefinition
Field Value
MulticastLoopbackPropertyDefinition
public static readonly Property<bool, Socket> MulticastLoopbackPropertyDefinition
Field Value
MulticastTtlPropertyDefinition
public static readonly Property<uint, Socket> MulticastTtlPropertyDefinition
Field Value
ProtocolPropertyDefinition
public static readonly Property<SocketProtocol, Socket> ProtocolPropertyDefinition
Field Value
TimeoutPropertyDefinition
public static readonly Property<uint, Socket> TimeoutPropertyDefinition
Field Value
TtlPropertyDefinition
public static readonly Property<uint, Socket> TtlPropertyDefinition
Field Value
TypePropertyDefinition
public static readonly Property<SocketType, Socket> TypePropertyDefinition
Field Value
Properties
Blocking
public bool Blocking { get; set; }
Property Value
Broadcast
public bool Broadcast { get; set; }
Property Value
Family
public SocketFamily Family { get; }
Property Value
Fd
public int Fd { get; }
Property Value
Keepalive
public bool Keepalive { get; set; }
Property Value
ListenBacklog
public int ListenBacklog { get; set; }
Property Value
MulticastLoopback
public bool MulticastLoopback { get; set; }
Property Value
MulticastTtl
public uint MulticastTtl { get; set; }
Property Value
Protocol
public SocketProtocol Protocol { get; }
Property Value
Timeout
public uint Timeout { get; set; }
Property Value
Ttl
public uint Ttl { get; set; }
Property Value
Type
public SocketType Type { get; }
Property Value
Methods
Accept(Cancellable?)
[Version("2.22")]
public Socket Accept(Cancellable? cancellable)
Parameters
cancellableCancellable
Returns
Bind(SocketAddress, bool)
[Version("2.22")]
public bool Bind(SocketAddress address, bool allowReuse)
Parameters
addressSocketAddressallowReusebool
Returns
CheckConnectResult()
[Version("2.22")]
public bool CheckConnectResult()
Returns
Close()
[Version("2.22")]
public bool Close()
Returns
ConditionCheck(IOCondition)
[Version("2.22")]
public IOCondition ConditionCheck(IOCondition condition)
Parameters
conditionIOCondition
Returns
ConditionTimedWait(IOCondition, long, Cancellable?)
[Version("2.32")]
public bool ConditionTimedWait(IOCondition condition, long timeoutUs, Cancellable? cancellable)
Parameters
conditionIOConditiontimeoutUslongcancellableCancellable
Returns
ConditionWait(IOCondition, Cancellable?)
[Version("2.22")]
public bool ConditionWait(IOCondition condition, Cancellable? cancellable)
Parameters
conditionIOConditioncancellableCancellable
Returns
ConditionWait(IOCondition, long, Cancellable?)
[Version("2.48")]
public bool ConditionWait(IOCondition condition, long timeout, Cancellable? cancellable)
Parameters
conditionIOConditiontimeoutlongcancellableCancellable
Returns
Connect(SocketAddress, Cancellable?)
[Version("2.22")]
public bool Connect(SocketAddress address, Cancellable? cancellable)
Parameters
addressSocketAddresscancellableCancellable
Returns
ConnectionFactoryCreateConnection()
[Version("2.22")]
public SocketConnection ConnectionFactoryCreateConnection()
Returns
CreateSource(IOCondition, Cancellable?)
[Version("2.22")]
public Source CreateSource(IOCondition condition, Cancellable? cancellable)
Parameters
conditionIOConditioncancellableCancellable
Returns
GetAvailableBytes()
[Version("2.32")]
public nint GetAvailableBytes()
Returns
GetBlocking()
[Version("2.22")]
public bool GetBlocking()
Returns
GetBroadcast()
[Version("2.32")]
public bool GetBroadcast()
Returns
GetCredentials()
[Version("2.26")]
public Credentials GetCredentials()
Returns
GetFamily()
[Version("2.22")]
public SocketFamily GetFamily()
Returns
GetFd()
[Version("2.22")]
public int GetFd()
Returns
GetGType()
public static Type GetGType()
Returns
GetKeepalive()
[Version("2.22")]
public bool GetKeepalive()
Returns
GetListenBacklog()
[Version("2.22")]
public int GetListenBacklog()
Returns
GetLocalAddress()
[Version("2.22")]
public SocketAddress GetLocalAddress()
Returns
GetMulticastLoopback()
[Version("2.32")]
public bool GetMulticastLoopback()
Returns
GetMulticastTtl()
[Version("2.32")]
public uint GetMulticastTtl()
Returns
GetOption(int, int, out int)
[Version("2.36")]
public bool GetOption(int level, int optname, out int value)
Parameters
Returns
GetProtocol()
[Version("2.22")]
public SocketProtocol GetProtocol()
Returns
GetRemoteAddress()
[Version("2.22")]
public SocketAddress GetRemoteAddress()
Returns
GetSocketType()
[Version("2.22")]
public SocketType GetSocketType()
Returns
GetTimeout()
[Version("2.26")]
public uint GetTimeout()
Returns
GetTtl()
[Version("2.32")]
public uint GetTtl()
Returns
Init(Cancellable?)
[Version("2.22")]
public bool Init(Cancellable? cancellable)
Parameters
cancellableCancellable
Returns
IsClosed()
[Version("2.22")]
public bool IsClosed()
Returns
IsConnected()
[Version("2.22")]
public bool IsConnected()
Returns
JoinMulticastGroup(InetAddress, bool, string?)
[Version("2.32")]
public bool JoinMulticastGroup(InetAddress group, bool sourceSpecific, string? iface)
Parameters
groupInetAddresssourceSpecificboolifacestring
Returns
JoinMulticastGroupSsm(InetAddress, InetAddress?, string?)
[Version("2.56")]
public bool JoinMulticastGroupSsm(InetAddress group, InetAddress? sourceSpecific, string? iface)
Parameters
groupInetAddresssourceSpecificInetAddressifacestring
Returns
LeaveMulticastGroup(InetAddress, bool, string?)
[Version("2.32")]
public bool LeaveMulticastGroup(InetAddress group, bool sourceSpecific, string? iface)
Parameters
groupInetAddresssourceSpecificboolifacestring
Returns
LeaveMulticastGroupSsm(InetAddress, InetAddress?, string?)
[Version("2.56")]
public bool LeaveMulticastGroupSsm(InetAddress group, InetAddress? sourceSpecific, string? iface)
Parameters
groupInetAddresssourceSpecificInetAddressifacestring
Returns
Listen()
[Version("2.22")]
public bool Listen()
Returns
New(SocketFamily, SocketType, SocketProtocol)
[Version("2.22")]
public static Socket New(SocketFamily family, SocketType type, SocketProtocol protocol)
Parameters
familySocketFamilytypeSocketTypeprotocolSocketProtocol
Returns
NewFromFd(int)
[Version("2.22")]
public static Socket NewFromFd(int fd)
Parameters
fdint
Returns
NewFromPointer(nint, bool)
Creates a new managed Socket instance for a given pointer.
public static Socket NewFromPointer(nint ptr, bool ownsHandle)
Parameters
Returns
NewWithProperties(ConstructArgument[])
Creates a new Socket and sets the properties specified by the construct arguments.
public static Socket NewWithProperties(ConstructArgument[] constructArguments)
Parameters
constructArgumentsConstructArgument[]The properties to set.
Returns
Receive(Span<byte>, Cancellable?)
[Version("2.22")]
public nint Receive(Span<byte> buffer, Cancellable? cancellable)
Parameters
bufferSpan<byte>cancellableCancellable
Returns
ReceiveBytes(nuint, long, Cancellable?)
[Version("2.80")]
public Bytes ReceiveBytes(nuint size, long timeoutUs, Cancellable? cancellable)
Parameters
sizenuinttimeoutUslongcancellableCancellable
Returns
ReceiveMessages(InputMessage[], int, Cancellable?)
[Version("2.48")]
public int ReceiveMessages(InputMessage[] messages, int flags, Cancellable? cancellable)
Parameters
messagesInputMessage[]flagsintcancellableCancellable
Returns
ReceiveMessages(InputMessage[], int, long, Cancellable?)
[Version("2.48")]
public int ReceiveMessages(InputMessage[] messages, int flags, long timeout, Cancellable? cancellable)
Parameters
messagesInputMessage[]flagsinttimeoutlongcancellableCancellable
Returns
ReceiveWithBlocking(Span<byte>, bool, Cancellable?)
[Version("2.26")]
public nint ReceiveWithBlocking(Span<byte> buffer, bool blocking, Cancellable? cancellable)
Parameters
bufferSpan<byte>blockingboolcancellableCancellable
Returns
Send(Span<byte>, Cancellable?)
[Version("2.22")]
public nint Send(Span<byte> buffer, Cancellable? cancellable)
Parameters
bufferSpan<byte>cancellableCancellable
Returns
SendMessages(OutputMessage[], int, Cancellable?)
[Version("2.44")]
public int SendMessages(OutputMessage[] messages, int flags, Cancellable? cancellable)
Parameters
messagesOutputMessage[]flagsintcancellableCancellable
Returns
SendMessages(OutputMessage[], int, long, Cancellable?)
[Version("2.48")]
public int SendMessages(OutputMessage[] messages, int flags, long timeout, Cancellable? cancellable)
Parameters
messagesOutputMessage[]flagsinttimeoutlongcancellableCancellable
Returns
SendTo(SocketAddress?, Span<byte>, Cancellable?)
[Version("2.22")]
public nint SendTo(SocketAddress? address, Span<byte> buffer, Cancellable? cancellable)
Parameters
addressSocketAddressbufferSpan<byte>cancellableCancellable
Returns
SendWithBlocking(Span<byte>, bool, Cancellable?)
[Version("2.26")]
public nint SendWithBlocking(Span<byte> buffer, bool blocking, Cancellable? cancellable)
Parameters
bufferSpan<byte>blockingboolcancellableCancellable
Returns
SetBlocking(bool)
[Version("2.22")]
public void SetBlocking(bool blocking)
Parameters
blockingbool
SetBroadcast(bool)
[Version("2.32")]
public void SetBroadcast(bool broadcast)
Parameters
broadcastbool
SetKeepalive(bool)
[Version("2.22")]
public void SetKeepalive(bool keepalive)
Parameters
keepalivebool
SetListenBacklog(int)
[Version("2.22")]
public void SetListenBacklog(int backlog)
Parameters
backlogint
SetMulticastLoopback(bool)
[Version("2.32")]
public void SetMulticastLoopback(bool loopback)
Parameters
loopbackbool
SetMulticastTtl(uint)
[Version("2.32")]
public void SetMulticastTtl(uint ttl)
Parameters
ttluint
SetOption(int, int, int)
[Version("2.36")]
public bool SetOption(int level, int optname, int value)
Parameters
Returns
SetTimeout(uint)
[Version("2.26")]
public void SetTimeout(uint timeout)
Parameters
timeoutuint
SetTtl(uint)
[Version("2.32")]
public void SetTtl(uint ttl)
Parameters
ttluint
Shutdown(bool, bool)
[Version("2.22")]
public bool Shutdown(bool shutdownRead, bool shutdownWrite)
Parameters
Returns
SpeaksIpv4()
[Version("2.22")]
public bool SpeaksIpv4()