network.sockets.ip - Palamecia/mint GitHub Wiki

Module network.sockets.ip

Description

load network.sockets.ip

This module provides the Network.IpSocket abstraction for IP-based sockets and the helper objects used to configure IPv4 and IPv6 behavior.

Packages

Enums

Network.IpSocketOption

This enum describes the options of an IP socket. The effective value of the option code can depend on the current system.

| Constant | Value | Description ||----------|-------|-------------|

| MCAST_BLOCK_SOURCE | 2 | Block multicast source. | | MCAST_JOIN_GROUP | 0 | Join multicast group. | | MCAST_JOIN_SOURCE_GROUP | 4 | Join source-specific multicast. | | MCAST_LEAVE_GROUP | 1 | Leave multicast group. | | MCAST_LEAVE_SOURCE_GROUP | 5 | Leave source-specific multicast. | | MCAST_UNBLOCK_SOURCE | 3 | Unblock multicast source. |

Network.IpV4SocketOption

This enum describes the options of an IP v4 socket. The effective value of the option code can depend on the current system.

| Constant | Value | Description ||----------|-------|-------------|

| ADD_MEMBERSHIP | 9 | Join or leave multicast group (Network.IpV4SocketOption.Network.IpV4Multicast... | | ADD_SOURCE_MEMBERSHIP | 13 | Join or leave source-specific multicast (Network.IpV4SocketOption.Network.IpV... | | BLOCK_SOURCE | 11 | Block or unblock multicast source (Network.IpV4SocketOption.Network.IpV4Multi... | | DROP_MEMBERSHIP | 10 | Join or leave multicast group (Network.IpV4SocketOption.Network.IpV4Multicast... | | DROP_SOURCE_MEMBERSHIP | 14 | Join or leave source-specific multicast (Network.IpV4SocketOption.Network.IpV... | | HDRINCL | 0 | IP header included with data (boolean). | | MULTICAST_IF | 6 | Specify outgoing interface (string). | | MULTICAST_LOOP | 8 | Specify loopback (boolean). | | MULTICAST_TTL | 7 | Specify outgoing TTL (number). | | OPTIONS | 1 | IP header options (number). | | RECVDSTADDR | 2 | Return destination IP address (boolean). | | RECVIF | 3 | Return received interface index (boolean). | | TOS | 4 | Type-of-service and precedence (number). | | TTL | 5 | TTL (number). | | UNBLOCK_SOURCE | 12 | Block or unblock multicast source (Network.IpV4SocketOption.Network.IpV4Multi... |

Network.IpV6SocketOption

This enum describes the options of an IP v6 socket. The effective value of the option code can depend on the current system.

| Constant | Value | Description ||----------|-------|-------------|

| CHECKSUM | 0 | Offset of checksum field for raw sockets (number). | | DONTFRAG | 1 | Drop instead of fragment large packets (boolean). | | JOIN_GROUP | 18 | Join multicast group (Network.IpV6SocketOption.Network.IpV6MulticastGroup, wr... | | LEAVE_GROUP | 19 | Leave multicast group (Network.IpV6SocketOption.Network.IpV6MulticastGroup, w... | | MULTICAST_HOPS | 16 | Specify outgoing hop limit (number). | | MULTICAST_IF | 15 | Specify outgoing interface (number). | | MULTICAST_LOOP | 17 | Specify loopback (boolean). | | NEXTHOP | 2 | Specify next-hop address. | | PATHMTU | 3 | Retrieve current path MTU. | | RECVDSTOPTS | 4 | Receive destination options (boolean). | | RECVHOPLIMIT | 5 | Receive unicast hop limit (boolean). | | RECVHOPOPTS | 6 | Receive hop-by-hop options (boolean). | | RECVPATHMTU | 7 | Receive path MTU (boolean). | | RECVPKTINFO | 8 | Receive packet information (boolean). | | RECVRTHDR | 9 | Receive source route (boolean). | | RECVTCLASS | 10 | Receive traffic class (boolean). | | UNICAT_HOPS | 11 | Default unicast hop limit (number). | | USE_MIN_MTU | 12 | Use minimum MTU (boolean). | | V6ONLY | 13 | Disable v4 compatibility (boolean). | | XXX | 14 | Sticky ancillary data (number). |

Classes

Network.AsyncIpSocket

This class provides an abstract interface to implement asynchronous socket classes that manage communication with a peer using one specific protocol from layer 4 of the OSI model over the IP protocol. It also implement the internal mechanisms of the interface.

Inherits

Public members

Modifiers Member Description
const shutdown Disable sends or receives on the socket if it was in the Network.AsyncIpSocke...

Package members

Modifiers Member Description
const getIpVersion Returns the IP version of the socket. This method calls the Network.AsyncIpSo...
const setIpVersion Sets the IP version of the socket. This method calls the Network.AsyncIpSocke...

Network.IpSocket

This class provides an abstract interface to implement socket classes that manage communication with a peer using one specific protocol from layer 4 of the OSI model over the IP protocol. It also implement the internal mechanisms of the interface.

Inherits

Public members

Modifiers Member Description
const finalizeConnection Finalize the connection to the peer. Return true if the connection succeed; o...
override const getSocketOption Returns the value of the socket option described by option. The option parame...
override const setSocketOption Sets the value of the socket option described by option to value. The option ...
const shutdown Disable sends or receives on the socket if it was in the Network.IpSocket.Net...

Package members

Modifiers Member Description
const getIpVersion Returns the IP version of the socket. The return value is either 4 or 6 for I...
const setIpVersion Sets the IP version of the socket. The ipVersion parameter must be either 4 or 6...

Private members

Modifiers Member Description
@ const g_lib Global library handle.
final ipVersion Internal IP version.

Network.IpV4MulticastGroup

This class provides multicast group information for IPv4 addresses.

Public members

Modifiers Member Description
const getInterfaceAddress Returns the local IPv4 address of the interface on which the multicast group ...
const getMulticastAddress Returns the address of the IPv4 multicast group.
const new Creates a new multicast group object for the given data. The data parameter c...
const setInterfaceAddress Sets the local IPv4 address of the interface on which the multicast group sho...
const setMulticastAddress Sets the address of the IPv4 multicast group. Returns true on success; otherw...

Package members

Modifiers Member Description
const to_ip_mreq Returns the pointer to the internal struct ip_mreq instance.

Private members

Modifiers Member Description
final d_ptr Object data.
@ const g_lib Global library handle.

Network.IpV4MulticastSourceGroup

This class provides multicast group information for IPv4 addresses.

Public members

Modifiers Member Description
const getInterfaceAddress Returns the local IPv4 address of the interface on which the multicast group ...
const getMulticastAddress Returns the address of the IPv4 multicast group.
const getSourceAddress Returns the address of the IPv4 multicast source.
const new Creates a new multicast group object for the given data. The data parameter c...
const setInterfaceAddress Sets the local IPv4 address of the interface on which the multicast group sho...
const setMulticastAddress Sets the address of the IPv4 multicast group. Returns true on success; otherw...
const setSourceAddress Sets the address of the IPv4 multicast source. Returns true on success; other...

Package members

Modifiers Member Description
const to_ip_mreq_source Returns the pointer to the internal struct ip_mreq_source instance.

Private members

Modifiers Member Description
final d_ptr Object data.
@ const g_lib Global library handle.

Network.IpV6MulticastGroup

This class provides multicast group information for IPv6 addresses.

Public members

Modifiers Member Description
const getInterfaceIndex Returns the interface index of the local interface on which the multicast gro...
const getMulticastAddress Returns the address of the IPv6 multicast group.
const new Creates a new multicast group object for the given data. The data parameter c...
const setInterfaceIndex Sets interface index of the local interface on which the multicast group shou...
const setMulticastAddress Sets the address of the IPv6 multicast group. Returns true on success; otherw...

Package members

Modifiers Member Description
const to_ipv6_mreq Returns the pointer to the internal struct ipv6_mreq instance.

Private members

Modifiers Member Description
final d_ptr Object data.
@ const g_lib Global library handle.

Descriptions

Network.AsyncIpSocket.getIpVersion

def (const self)

Returns the IP version of the socket. This method calls the Network.IpSocket.getIpVersion method of the underlying socket.

Network.AsyncIpSocket.setIpVersion

def (self, ipVersion)

Sets the IP version of the socket. This method calls the Network.IpSocket.setIpVersion method of the underlying socket.

Network.AsyncIpSocket.shutdown

def (self)

Disable sends or receives on the socket if it was in the Network.Socket.State.Connected state or stops listening if it was in the Network.Socket.State.Listening state. Returns true if the operation was completed or false if it can't be performed synchronously.

On success, the socket enter the Network.Socket.State.Closing state.

An instance of Exception.SocketError is raised on error.

Network.IpSocket.finalizeConnection

def (self)

Finalize the connection to the peer. Return true if the connection succeed; otherwise returns false. On success, the end point enter the Network.Socket.State.Connected state.

An instance of Exception.SocketError is raised on error.

Network.IpSocket.g_lib

lib ('libmint-network')

Global library handle.

Network.IpSocket.getIpVersion

def (const self)

Returns the IP version of the socket. The return value is either 4 or 6 for IPv4 and IPv6 sockets, respectively.

Network.IpSocket.getSocketOption

def (self, % option)

Returns the value of the socket option described by option. The option parameter must be a value of the Network.IpV4SocketOption, Network.IpV6SocketOption, Network.IpSocketOption or Network.SocketOption enum.

An instance of Exception.SocketError is raised on error.

Network.IpSocket.ipVersion

none

Internal IP version.

Network.IpSocket.setIpVersion

def (self, ipVersion)

Sets the IP version of the socket. The ipVersion parameter must be either 4 or 6 for IPv4 and IPv6 sockets, respectively.

Network.IpSocket.setSocketOption

def (self, % option, value)

Sets the value of the socket option described by option to value. The option parameter must be a value of the Network.IpV4SocketOption, Network.IpV6SocketOption, Network.IpSocketOption or Network.SocketOption enum.

An instance of Exception.SocketError is raised on error.

Network.IpSocket.shutdown

def (self)

Disable sends or receives on the socket if it was in the Network.Socket.State.Connected state or stops listening if it was in the Network.Socket.State.Listening state. Returns true if the operation was completed or false if it can't be performed synchronously.

On success, the socket enter the Network.Socket.State.Closing state.

An instance of Exception.SocketError is raised on error.

Network.IpSocketOption.MCAST_BLOCK_SOURCE

2

Block multicast source.

Network.IpSocketOption.MCAST_JOIN_GROUP

0

Join multicast group.

Network.IpSocketOption.MCAST_JOIN_SOURCE_GROUP

4

Join source-specific multicast.

Network.IpSocketOption.MCAST_LEAVE_GROUP

1

Leave multicast group.

Network.IpSocketOption.MCAST_LEAVE_SOURCE_GROUP

5

Leave source-specific multicast.

Network.IpSocketOption.MCAST_UNBLOCK_SOURCE

3

Unblock multicast source.

Network.IpV4MulticastGroup.d_ptr

null

Object data.

Network.IpV4MulticastGroup.g_lib

lib ('libmint-network')

Global library handle.

Network.IpV4MulticastGroup.getInterfaceAddress

def (const self)

Returns the local IPv4 address of the interface on which the multicast group should be joined or dropped.

Network.IpV4MulticastGroup.getMulticastAddress

def (const self)

Returns the address of the IPv4 multicast group.

Network.IpV4MulticastGroup.new

def (self, data)

Creates a new multicast group object for the given data. The data parameter can be an instance of Network.IpV4MulticastGroup, in this case the object is returned as the new instance, or an instance of the ip_mreq C struct. The parameter can also provide a toIpV4MulticastGroup method that will be used to create the object.

def (self, const multiaddr, const interface)

Creates a new multicast group object. The multiaddr parameter must be a string used to specifies the address of the IPv4 multicast group. The interface parameter must be a string used to specifies the local IPv4 address of the interface. If this parameter specifies an IPv4 address of 0.0.0.0, the default IPv4 multicast interface is used.

Network.IpV4MulticastGroup.setInterfaceAddress

def (const self, const address)

Sets the local IPv4 address of the interface on which the multicast group should be joined or dropped. This value is in network byte order. If this member specifies an IPv4 address of 0.0.0.0, the default IPv4 multicast interface is used. Returns true on success; otherwise returns false.

Network.IpV4MulticastGroup.setMulticastAddress

def (const self, const address)

Sets the address of the IPv4 multicast group. Returns true on success; otherwise returns false.

Network.IpV4MulticastGroup.to_ip_mreq

def (const self)

Returns the pointer to the internal struct ip_mreq instance.

Network.IpV4MulticastSourceGroup.d_ptr

null

Object data.

Network.IpV4MulticastSourceGroup.g_lib

lib ('libmint-network')

Global library handle.

Network.IpV4MulticastSourceGroup.getInterfaceAddress

def (const self)

Returns the local IPv4 address of the interface on which the multicast group should be joined, dropped, blocked, or unblocked.

Network.IpV4MulticastSourceGroup.getMulticastAddress

def (const self)

Returns the address of the IPv4 multicast group.

Network.IpV4MulticastSourceGroup.getSourceAddress

def (const self)

Returns the address of the IPv4 multicast source.

Network.IpV4MulticastSourceGroup.new

def (self, data)

Creates a new multicast group object for the given data. The data parameter can be an instance of Network.IpV4MulticastSourceGroup, in this case the object is returned as the new instance, or an instance of the ip_mreq_source C struct. The parameter can also provide a toIpV4MulticastSourceGroup method that will be used to create the object.

def (self, const multiaddr, const sourceaddr, const interface)

Creates a new multicast group object. The multiaddr parameter must be a string used to specifies the address of the IPv4 multicast group. The sourceaddr parameter must be a string used to specifies the address of the IPv4 multicast source. The interface parameter must be a string used to specifies the local IPv4 address of the interface. If this parameter specifies an IPv4 address of 0.0.0.0, the default IPv4 multicast interface is used.

Network.IpV4MulticastSourceGroup.setInterfaceAddress

def (const self, const address)

Sets the local IPv4 address of the interface on which the multicast group should be joined, dropped, blocked, or unblocked. This value is in network byte order. If this method specifies an IPv4 address of 0.0.0.0, the default IPv4 multicast interface is used. Returns true on success; otherwise returns false.

Network.IpV4MulticastSourceGroup.setMulticastAddress

def (const self, const address)

Sets the address of the IPv4 multicast group. Returns true on success; otherwise returns false.

Network.IpV4MulticastSourceGroup.setSourceAddress

def (const self, const address)

Sets the address of the IPv4 multicast source. Returns true on success; otherwise returns false.

Network.IpV4MulticastSourceGroup.to_ip_mreq_source

def (const self)

Returns the pointer to the internal struct ip_mreq_source instance.

Network.IpV4SocketOption.ADD_MEMBERSHIP

9

Join or leave multicast group (Network.IpV4MulticastGroup, write only).

Network.IpV4SocketOption.ADD_SOURCE_MEMBERSHIP

13

Join or leave source-specific multicast (Network.IpV4MulticastSourceGroup, write only).

Network.IpV4SocketOption.BLOCK_SOURCE

11

Block or unblock multicast source (Network.IpV4MulticastSourceGroup, write only).

Network.IpV4SocketOption.DROP_MEMBERSHIP

10

Join or leave multicast group (Network.IpV4MulticastGroup, write only).

Network.IpV4SocketOption.DROP_SOURCE_MEMBERSHIP

14

Join or leave source-specific multicast (Network.IpV4MulticastSourceGroup, write only).

Network.IpV4SocketOption.HDRINCL

0

IP header included with data (boolean).

Network.IpV4SocketOption.MULTICAST_IF

6

Specify outgoing interface (string).

Network.IpV4SocketOption.MULTICAST_LOOP

8

Specify loopback (boolean).

Network.IpV4SocketOption.MULTICAST_TTL

7

Specify outgoing TTL (number).

Network.IpV4SocketOption.OPTIONS

1

IP header options (number).

Network.IpV4SocketOption.RECVDSTADDR

2

Return destination IP address (boolean).

Network.IpV4SocketOption.RECVIF

3

Return received interface index (boolean).

Network.IpV4SocketOption.TOS

4

Type-of-service and precedence (number).

Network.IpV4SocketOption.TTL

5

TTL (number).

Network.IpV4SocketOption.UNBLOCK_SOURCE

12

Block or unblock multicast source (Network.IpV4MulticastSourceGroup, write only).

Network.IpV6MulticastGroup.d_ptr

null

Object data.

Network.IpV6MulticastGroup.g_lib

lib ('libmint-network')

Global library handle.

Network.IpV6MulticastGroup.getInterfaceIndex

def (const self)

Returns the interface index of the local interface on which the multicast group should be joined or dropped.

Network.IpV6MulticastGroup.getMulticastAddress

def (const self)

Returns the address of the IPv6 multicast group.

Network.IpV6MulticastGroup.new

def (self, data)

Creates a new multicast group object for the given data. The data parameter can be an instance of Network.IpV6MulticastGroup, in this case the object is returned as the new instance, or an instance of the ipv6_mreq C struct. The parameter can also provide a toIpV6MulticastGroup method that will be used to create the object.

def (self, const multiaddr, const interface)

Creates a new multicast group object. The multiaddr parameter must be a string used to specifies the address of the IPv6 multicast group. The interface parameter must be a number used to specifies the index of the local interfaceon which the multicast group should be joined or dropped. If this parameter specifies an interface index of 0, the default multicast interface is used.

Network.IpV6MulticastGroup.setInterfaceIndex

def (const self, const index)

Sets interface index of the local interface on which the multicast group should be joined or dropped. If this method specifies an interface index of 0, the default multicast interface is used.

Network.IpV6MulticastGroup.setMulticastAddress

def (const self, const address)

Sets the address of the IPv6 multicast group. Returns true on success; otherwise returns false.

Network.IpV6MulticastGroup.to_ipv6_mreq

def (const self)

Returns the pointer to the internal struct ipv6_mreq instance.

Network.IpV6SocketOption.CHECKSUM

0

Offset of checksum field for raw sockets (number).

Network.IpV6SocketOption.DONTFRAG

1

Drop instead of fragment large packets (boolean).

Network.IpV6SocketOption.JOIN_GROUP

18

Join multicast group (Network.IpV6MulticastGroup, write only).

Network.IpV6SocketOption.LEAVE_GROUP

19

Leave multicast group (Network.IpV6MulticastGroup, write only).

Network.IpV6SocketOption.MULTICAST_HOPS

16

Specify outgoing hop limit (number).

Network.IpV6SocketOption.MULTICAST_IF

15

Specify outgoing interface (number).

Network.IpV6SocketOption.MULTICAST_LOOP

17

Specify loopback (boolean).

Network.IpV6SocketOption.NEXTHOP

2

Specify next-hop address.

Network.IpV6SocketOption.PATHMTU

3

Retrieve current path MTU.

Network.IpV6SocketOption.RECVDSTOPTS

4

Receive destination options (boolean).

Network.IpV6SocketOption.RECVHOPLIMIT

5

Receive unicast hop limit (boolean).

Network.IpV6SocketOption.RECVHOPOPTS

6

Receive hop-by-hop options (boolean).

Network.IpV6SocketOption.RECVPATHMTU

7

Receive path MTU (boolean).

Network.IpV6SocketOption.RECVPKTINFO

8

Receive packet information (boolean).

Network.IpV6SocketOption.RECVRTHDR

9

Receive source route (boolean).

Network.IpV6SocketOption.RECVTCLASS

10

Receive traffic class (boolean).

Network.IpV6SocketOption.UNICAT_HOPS

11

Default unicast hop limit (number).

Network.IpV6SocketOption.USE_MIN_MTU

12

Use minimum MTU (boolean).

Network.IpV6SocketOption.V6ONLY

13

Disable v4 compatibility (boolean).

Network.IpV6SocketOption.XXX

14

Sticky ancillary data (number).