Struct

struct OptionLevel

public struct OptionLevel {
    public static const ICMP: Int32
    public static const IP: Int32
    public static const RAW: Int32
    public static const SOCKET: Int32
    public static const TCP: Int32
    public static const UDP: Int32
}

Description: Provides common socket option levels.

static const ICMP

public static const ICMP: Int32

Description: Controls the socket option level of the ICMP protocol behavior.

Type: Int32

static const IP

public static const IP: Int32

Description: Controls the socket option level of the IP protocol behavior.

Type: Int32

static const RAW

public static const RAW: Int32

Description: Controls the socket option level of the RAW protocol behavior.

Type: Int32

static const SOCKET

public static const SOCKET: Int32

Description: Controls the socket option level of basic socket behavior.

Type: Int32

static const TCP

public static const TCP: Int32

Description: Controls the socket option level of the TCP protocol behavior.

Type: Int32

static const UDP

public static const UDP: Int32

Description: Controls the socket option level of the UDP protocol behavior.

Type: Int32

struct OptionName

public struct OptionName {
    public static const IP_HDRINCL: Int32
    public static const IP_TOS: Int32
    public static const IP_TTL: Int32
    public static const SO_ACCEPTCONN: Int32
    public static const SO_BROADCAST: Int32
    public static const SO_DEBUG: Int32
    public static const SO_DONTROUTE: Int32
    public static const SO_ERROR: Int32
    public static const SO_KEEPALIVE: Int32
    public static const SO_LINGER: Int32
    public static const SO_OOBINLINE: Int32
    public static const SO_RCVBUF: Int32
    public static const SO_RCVTIMEO: Int32
    public static const SO_REUSEADDR: Int32
    public static const SO_SNDBUF: Int32
    public static const SO_SNDTIMEO: Int32
    public static const TCP_KEEPCNT: Int32
    public static const TCP_KEEPIDLE: Int32
    public static const TCP_KEEPINTVL: Int32
    public static const TCP_NODELAY: Int32
}

Description: Provides common socket options.

static const IP_HDRINCL

public static const IP_HDRINCL: Int32

Description: Specifies the socket option used to check whether the IP header is a socket option provided by an application when a packet is being sent.

Type: Int32

static const IP_TOS

public static const IP_TOS: Int32

Description: Indicates the socket option used to specify the service type and priority of a packet.

Type: Int32

static const IP_TTL

public static const IP_TTL: Int32

Description: Specifies the socket option used to limit the maximum number of hops for transmitting IP packets on the network.

Type: Int32

static const SO_ACCEPTCONN

public static const SO_ACCEPTCONN: Int32

Description: Specifies the socket option used to query whether a socket is in the listening state.

Type: Int32

static const SO_BROADCAST

public static const SO_BROADCAST: Int32

Description: Specifies the socket option used to set whether a socket permits sending broadcast messages.

Type: Int32

static const SO_DEBUG

public static const SO_DEBUG: Int32

Description: Specifies the socket option used to enable or disable the debug mode.

Type: Int32

static const SO_DONTROUTE

public static const SO_DONTROUTE: Int32

Description: Specifies the socket option used to avoid routing socket packets during socket connection.

Type: Int32

static const SO_ERROR

public static const SO_ERROR: Int32

Description: Specifies the socket option used to obtain and clear the error state of a socket.

Type: Int32

static const SO_KEEPALIVE

public static const SO_KEEPALIVE: Int32

Description: Specifies the socket option used to check whether the TCP connection is still active.

Type: Int32

static const SO_LINGER

public static const SO_LINGER: Int32

Description: Specifies the socket option used to set the behavior of closing a socket.

Type: Int32

static const SO_OOBINLINE

public static const SO_OOBINLINE: Int32

Description: Specifies the socket option used to control the mode of receiving out-of-band data.

Type: Int32

static const SO_RCVBUF

public static const SO_RCVBUF: Int32

Description: Specifies the socket option used to set the size of the receive buffer of the socket.

Type: Int32

static const SO_RCVTIMEO

public static const SO_RCVTIMEO: Int32

Description: Specifies the socket option used to set the timeout interval for the socket to receive data.

Type: Int32

static const SO_REUSEADDR

public static const SO_REUSEADDR: Int32

Description: Specifies the socket option used to release the bound port immediately after the socket is closed so that other sockets can be immediately bound to the port.

Type: Int32

static const SO_SNDBUF

public static const SO_SNDBUF: Int32

Description: Specifies the socket option used to set the size of the send buffer of the socket.

Type: Int32

static const SO_SNDTIMEO

public static const SO_SNDTIMEO: Int32

Description: Specifies the socket option used to set the timeout interval for the socket to send data.

Type: Int32

static const TCP_KEEPCNT

public static const TCP_KEEPCNT: Int32

Description: Specifies the socket option used to control the number of keepalive probe packets sent over a TCP connection.

Type: Int32

static const TCP_KEEPIDLE

public static const TCP_KEEPIDLE: Int32

Description: Specifies the socket option used to set the maximum number of times a TCP connection is maintained when no acknowledgment is received from the peer end.

Type: Int32

static const TCP_KEEPINTVL

public static const TCP_KEEPINTVL: Int32

Description: Specifies the socket option used to set the interval for sending probe packets when the TCP connection is maintained.

Type: Int32

static const TCP_NODELAY

public static const TCP_NODELAY: Int32

Description: Specifies the socket option used to control the delay behavior of the TCP protocol.

Type: Int32

struct ProtocolType

public struct ProtocolType <: Equatable<ProtocolType> & ToString & Hashable {
    public static let ICMP: ProtocolType
    public static let IPV4: ProtocolType
    public static let IPV6: ProtocolType
    public static let RAW: ProtocolType
    public static let TCP: ProtocolType
    public static let UDP: ProtocolType
    public static let Unspecified: ProtocolType
    public init(protocol: Int32)
}

Description: Provides common socket protocols, and allows the socket protocols to be constructed by specifying the value of Int32.

Parent Type:

static let ICMP

public static let ICMP: ProtocolType

Description: Sets the protocol type to ICMP.

Type: ProtocolType

static let IPV4

public static let IPV4: ProtocolType

Description: Sets the protocol type to IPV4.

Type: ProtocolType

static let IPV6

public static let IPV6: ProtocolType

Description: Sets the protocol type to IPV6.

Type: ProtocolType

static let RAW

public static let RAW: ProtocolType

Description: Sets the protocol type to RAW.

Type: ProtocolType

static let TCP

public static let TCP: ProtocolType

Description: Sets the protocol type to TCP.

Type: ProtocolType

static let UDP

public static let UDP: ProtocolType

Description: Sets the protocol type to UDP.

Type: ProtocolType

static let Unspecified

public static let Unspecified: ProtocolType

Description: Leaves the protocol type unspecified.

Type: ProtocolType

init(Int32)

public init(protocol: Int32)

Description: Creates a protocol by specifying the socket protocol value.

Parameters:

  • protocol: Int32: socket protocol value

func hashCode()

public func hashCode(): Int64

Description: Returns the hash value of the current ProtocolType instance.

Returns:

func toString()

public func toString(): String

Description: Returns the string representation of the current ProtocolType instance.

Returns:

  • [String](../../core/core_package_api/core_package_structs.md#struct-string): string representation of the current ProtocolType instance

operator func !=(ProtocolType)

public operator func !=(r: ProtocolType): Bool

Description: Checks whether two ProtocolType instances are not equal.

Parameters:

Returns:

  • Bool: If the Int32 values represented by the two instances are not equal, true is returned. Otherwise, false is returned.

operator func ==(ProtocolType)

public operator func ==(r: ProtocolType): Bool

Description: Checks whether two ProtocolType instances are equal.

Parameters:

Returns:

  • Bool: If the Int32 values represented by the two instances are equal, true is returned. Otherwise, false is returned.

struct RawAddress

public struct RawAddress {
    public init(addr: Array<Byte>)
}

Description: Creates and obtains the communication address of RawSocket.

prop addr

public prop addr: Array<Byte>

Description: Obtains the address.

Type: Array<Byte>

init(Array<Byte>)

public init(addr: Array<Byte>)

Description: Creates an address based on a byte array.

Parameters:

  • addr: Array<Byte>: byte array of the storage address

struct SocketDomain

public struct SocketDomain <: Equatable<SocketDomain> & ToString & Hashable {
    public static let IPV4: SocketDomain
    public static let IPV6: SocketDomain
    public static let NETLINK: SocketDomain
    public static let PACKET: SocketDomain
    public static let UNIX: SocketDomain
    public init(domain: Int32)
}

Description: Provides common socket communication domains, and allows the socket communication domains to be constructed by specifying the value of Int32.

Parent Type:

static let IPV4

public static let IPV4: SocketDomain

Description: Specifies the IPV4 communication domain.

Type: SocketDomain

static let IPV6

public static let IPV6: SocketDomain

Description: Specifies the IPV6 communication domain.

Type: SocketDomain

public static let NETLINK: SocketDomain

Description: Specifies the communication between the kernel space process and the userspace process.

Note:

  • The Windows platform does not provide this constant.

Type: SocketDomain

static let PACKET

public static let PACKET: SocketDomain

Description: Provides userspace applications with direct access to network packets.

Note:

  • The Windows platform does not provide this constant.

Type: SocketDomain

static let UNIX

public static let UNIX: SocketDomain

Description: Supports local communication.

Type: SocketDomain

init(Int32)

public init(domain: Int32)

Description: Creates a socket communication domain based on the specified communication domain value.

Parameters:

  • domain: Int32: communication domain value

func hashCode()

public func hashCode(): Int64

Description: Returns the hash value of the current SocketDomain instance.

Returns:

func toString()

public func toString(): String

Description: Returns the string representation of the current SocketDomain instance.

Returns:

  • [String](../../core/core_package_api/core_package_structs.md#struct-string): string representation of the current SocketDomain instance

operator func !=(SocketDomain)

public operator func !=(r: SocketDomain): Bool

Description: Compares whether two SocketDomain instances are not equal.

Parameters:

Returns:

  • Bool: If the Int32 values represented by the two instances are not equal, true is returned. Otherwise, false is returned.

operator func ==(SocketDomain)

public operator func ==(r: SocketDomain): Bool

Description: Compares whether two SocketDomain instances are equal.

Parameters:

Returns:

  • Bool: If the Int32 values represented by the two instances are equal, true is returned. Otherwise, false is returned.

struct SocketKeepAliveConfig

public struct SocketKeepAliveConfig <: ToString & Equatable<SocketKeepAliveConfig> {
    public let count: UInt32
    public let idle: Duration
    public let interval: Duration
    public init(idle!: Duration = Duration.second * 45, interval!: Duration = Duration.second * 5, count!: UInt32 = 5)
}

Description: Configures the TCP KeepAlive attribute.

Parent Type:

let count

public let count: UInt32

Description: Queries the number of packets indicating whether the connection is invalid.

Type: UInt32

let idle

public let idle: Duration

Description: Specifies the duration in which a connection is allowed to be idle. If the duration exceeds a threshold, the connection is terminated.

Type: Duration

let interval

public let interval: Duration

Description: Specifies the interval for sending keepalive packets.

Type: Duration

init(Duration, Duration, UInt32)

public init(idle!: Duration = Duration.second * 45, interval!: Duration = Duration.second * 5, count!: UInt32 = 5)

Description: Initializes the SocketKeepAliveConfig instance object.

Parameters:

  • idle!: Duration: duration allowed to be idle. The default value is 45 seconds.
  • interval!: Duration: interval for sending keepalive packets. The default value is 45 seconds.
  • count!: UInt32: number of packets indicating whether a connection is invalid. The default value is 5.

Throws:

func toString()

public override func toString(): String

Description: Converts the TCP KeepAlive attribute into a string.

Returns:

  • String: string obtained through conversion

operator func !=(SocketKeepAliveConfig)

public override operator func !=(other: SocketKeepAliveConfig): Bool

Description: Checks whether two SocketKeepAliveConfig instances are not equal.

Parameters:

Returns:

  • Bool: If they are not equal, true is returned. Otherwise, false is returned.

operator func ==(SocketKeepAliveConfig)

public override operator func ==(other: SocketKeepAliveConfig): Bool

Description: Checks whether two SocketKeepAliveConfig instances are equal.

Parameters:

Returns:

  • Bool: If they are equal, true is returned. Otherwise, false is returned.

struct SocketOptions

public struct SocketOptions {
    public static const IPPROTO_TCP
    public static const IPPROTO_UDP
    public static const SOL_SOCKET
    public static const SO_BINDTODEVICE
    public static const SO_KEEPALIVE
    public static const SO_LINGER
    public static const SO_RCVBUF
    public static const SO_REUSEADDR
    public static const SO_REUSEPORT
    public static const SO_SNDBUF
    public static const TCP_NODELAY
    public static const TCP_QUICKACK
}

Description: SocketOptions stores some constants for setting socket options for subsequent calling.

const IPPROTO_TCP

public static const IPPROTO_TCP: Int32 = IPPROTO_TCP

Description: Specifies the constant used to set level of a socket option to IPPROTO_TCP.

Type: Int32

const IPPROTO_UDP

public static const IPPROTO_UDP: Int32 = IPPROTO_UDP

Description: Specifies the constant used to set level of a socket option to IPPROTO_UDP.

Type: Int32

const SOL_SOCKET

public static const SOL_SOCKET: Int32 = SOL_SOCKET

Description: Specifies the constant used to set level of a socket option to SOL_SOCKET.

Type: Int32

const SO_BINDTODEVICE

public static const SO_BINDTODEVICE: Int32 = SOCK_BINDTODEVICE

Description: Specifies the constant used to set optname of a socket option to SO_BINDTODEVICE.

Type: Int32

const SO_KEEPALIVE

public static const SO_KEEPALIVE: Int32 = SOCK_KEEPALIVE

Description: Specifies the constant used to set optname of a socket option to SO_KEEPALIVE.

Type: Int32

const SO_LINGER

public static const SO_LINGER: Int32 = SOCK_LINGER

Description: Specifies the constant used to set optname of a socket option to SO_LINGER.

Type: Int32

const SO_RCVBUF

public static const SO_RCVBUF: Int32 = SOCK_RCVBUF

Description: Specifies the constant used to set optname of a socket option to SO_RCVBUF.

Type: Int32

const SO_REUSEADDR

public static const SO_REUSEADDR: Int32 = SOCK_REUSEADDR

Description: Specifies the constant used to set optname of a socket option to SO_REUSEADDR.

Type: Int32

const SO_REUSEPORT

public static const SO_REUSEPORT: Int32 = SOCK_REUSEPORT

Description: Specifies the constant used to set optname of a socket option to SO_REUSEPORT.

Type: Int32

const SO_SNDBUF

public static const SO_SNDBUF: Int32 = SOCK_SNDBUF

Description: Specifies the constant used to set optname of a socket option to SO_SNDBUF.

Type: Int32

const TCP_NODELAY

public static const TCP_NODELAY: Int32 = SOCK_TCP_NODELAY

Description: Specifies the constant used to set optname of a socket option to TCP_NODELAY.

Type: Int32

const TCP_QUICKACK

public static const TCP_QUICKACK: Int32 = SOCK_TCP_QUICKACK

Description: Specifies the constant used to set optname of a socket option to TCP_QUICKACK.

Type: Int32

struct SocketType

public struct SocketType <: Equatable<SocketType> & ToString & Hashable {
    public static let DATAGRAM: SocketType
    public static let RAW: SocketType
    public static let SEQPACKET: SocketType
    public static let STREAM: SocketType
    public init(`type`: Int32)
}

Description: Provides common socket types and allows the socket types to be constructed by specifying the value of Int32.

Parent Type:

static let DATAGRAM

public static let DATAGRAM: SocketType

Description: Specifies the packet socket type.

Type: SocketType

static let RAW

public static let RAW: SocketType

Description: Specifies the raw socket type.

Type: SocketType

static let SEQPACKET

public static let SEQPACKET: SocketType

Description: Specifies the sequenced packet socket type.

Type: SocketType

static let STREAM

public static let STREAM: SocketType

Description: Specifies the stream socket type.

Type: SocketType

init(Int32)

public init(`type`: Int32)

Description: Creates a socket type by specifying the socket type value.

Parameters:

  • `type`: Int32: socket type value

func hashCode()

public func hashCode(): Int64

Description: Returns the hash value of the current SocketType instance.

Returns:

func toString()

public func toString(): String

Description: Returns the string representation of the current SocketType instance.

Returns:

operator func !=(SocketType)

public operator func !=(r: SocketType): Bool

Description: Checks whether two SocketType instances are not equal.

Parameters:

Returns:

  • Bool: If the Int32 values represented by the two instances are not equal, true is returned. Otherwise, false is returned.

operator func ==(SocketType)

public operator func ==(r: SocketType): Bool

Description: Checks whether two SocketType instances are equal.

Parameters:

Returns:

  • Bool: If the Int32 values represented by the two instances are equal, true is returned. Otherwise, false is returned.