network.sockets.udp - Palamecia/mint GitHub Wiki

Module network.sockets.udp

Description

load network.sockets.udp

This module provides the Network.UdpSocket implementation for UDP/IP communication and its scheduler-based asynchronous companion.

Packages

Classes

Network.AsyncUdpSocket

Inherits

Public members

Modifiers Member Description
class ReadFromOperation Scheduler operation used to receive data asynchronously. Instances of this op...
class ReadOperation Scheduler operation used to receive data asynchronously. Instances of this op...
class WriteOperation Scheduler operation used to send data asynchronously. Instances of this opera...
class WriteToOperation Scheduler operation used to send data asynchronously. Instances of this opera...
const bind Tells the socket to listen for incoming messages from endpoint. Returns true ...
const connect Attempts to make a connection to the device identified by the endpoint parame...
const open Attempts to open the socket without connection to the remote device. The sock...
read Returns all available data received from the peer as an instance of Network.A...
readFrom Asynchronously receives a data from any peer. The operation suspends the curr...
write Sends the data described by the data parameter to the peer. The data paramete...
writeTo Asynchronously sends the data described by the data parameter to the peer des...

Private members

Modifiers Member Description
@ const g_lib Global library handle.

Network.AsyncUdpSocket.ReadFromOperation

Scheduler operation used to receive data asynchronously.

Instances of this operation are created by Network.UdpSocket.readFrom.

The operation asynchronously receives a datagram from the socket. The coroutine is suspended until a datagram is received, at which point the operation completes with the received data and the sender's address.

An instance of Exception.SocketError is raised on error.

Inherits

Public members

Modifiers Member Description
override const check Checks for the operation completion. The operation succeed if data is availab...
override const get Returns the received data as an instance of Network.AsyncUdpSocket.ReadFromOp...
const new Creates a new asynchronous operation to read data from socket.

Protected members

Modifiers Member Description
override const setup

Private members

Modifiers Member Description
final buffer Internal read buffer.
final endpoint Internal peer endpoint.
@ const g_lib Global library handle.
final socket Internal socket.

Network.AsyncUdpSocket.ReadOperation

Scheduler operation used to receive data asynchronously.

Instances of this operation are created by Network.AsyncUdpSocket.read.

The operation asynchronously receives a datagram from the socket. The coroutine is suspended until a datagram is received, at which point the operation completes with the received data.

An instance of Exception.SocketError is raised on error.

Inherits

Public members

Modifiers Member Description
override const check Checks for the operation completion. The operation succeed if data is availab...
override const get Returns the received data as an instance of Network.AsyncUdpSocket.ReadOperat...
const new Creates a new asynchronous operation to read data from socket until the compl...

Protected members

Modifiers Member Description
override const setup

Private members

Modifiers Member Description
final buffer Internal read buffer.
final completion Internal combination condition.
@ const g_lib Global library handle.
final socket Internal socket.

Network.AsyncUdpSocket.WriteOperation

Scheduler operation used to send data asynchronously.

Instances of this operation are created by Network.AsyncUdpSocket.write.

The operation asynchronously sends the provided Serializer.DataStream as a datagram using the socket.

The coroutine is suspended until the datagram send operation completes.

Returns an iterator containing true and the amount of sent data in bytes if the data was successfully sent to the peer; otherwise returns false.

An instance of Exception.SocketError is raised on error.

Inherits

Public members

Modifiers Member Description
override const check Checks for the operation completion. The operation succeed if all the data in...
override const get Returns an iterator containing true and the amount of sent data in bytes if t...
const new Creates a new asynchronous operation to send the data provided by buffer to s...

Protected members

Modifiers Member Description
override const setup

Private members

Modifiers Member Description
final buffer Internal write buffer.
final count Internal sent byte counter.
@ const g_lib Global library handle.
final socket Internal socket.
final status Internal write status.

Network.AsyncUdpSocket.WriteToOperation

Scheduler operation used to send data asynchronously.

Instances of this operation are created by Network.AsyncUdpSocket.writeTo.

The operation asynchronously sends the provided Serializer.DataStream as a datagram to the specified destination address.

The coroutine is suspended until the datagram send operation completes.

Returns an iterator containing true and the amount of sent data in bytes if the data was successfully sent to the peer; otherwise returns false.

An instance of Exception.SocketError is raised on error.

Inherits

Public members

Modifiers Member Description
override const check Checks for the operation completion. The operation succeed if all the data in...
override const get Returns an iterator containing true and the amount of sent data in bytes if t...
const new Creates a new asynchronous operation to send the data provided by buffer to t...

Protected members

Modifiers Member Description
override const setup

Private members

Modifiers Member Description
final buffer Internal write buffer.
final count Internal sent byte counter.
final endpoint Internal peer endpoint.
@ const g_lib Global library handle.
final socket Internal socket.
final status Internal write status.

Network.UdpSocket

This class provides an end point implementation for communication with a peer device using the UDP/IP protocol.

Inherits

Public members

Modifiers Member Description
const asyncOn Returns a new instance of Network.UdpSocket.Network.AsyncUdpSocket initialize...
const bind Tells the socket to listen for incoming messages from endpoint. Returns true ...
const connect Attempts to make a connection to the device identified by the endpoint parame...
const open Attempts to open the socket without connection to the remote device. The sock...
const read Returns all available data received from the peer as an instance of Network.U...
const readFrom Returns an iterator containing the available data received from any peer as a...
const write Sends the data described by the data parameter to the peer. The data paramete...
const writeTo Sends the data described by the data parameter to the peer described by endpoint...

Private members

Modifiers Member Description
@ const g_lib Global library handle.

Descriptions

Network.AsyncUdpSocket.ReadFromOperation.buffer

null

Internal read buffer.

Network.AsyncUdpSocket.ReadFromOperation.check

def (self, result)

Checks for the operation completion. The operation succeed if data is available. It fails on error.

Network.AsyncUdpSocket.ReadFromOperation.endpoint

null

Internal peer endpoint.

Network.AsyncUdpSocket.ReadFromOperation.g_lib

lib ('libmint-network')

Global library handle.

Network.AsyncUdpSocket.ReadFromOperation.get

def (self)

Returns the received data as an instance of Serializer.DataStream.

Network.AsyncUdpSocket.ReadFromOperation.new

def (self, socket)

Creates a new asynchronous operation to read data from socket.

Network.AsyncUdpSocket.ReadFromOperation.setup

def (self, scheduler)

Network.AsyncUdpSocket.ReadFromOperation.socket

null

Internal socket.

Network.AsyncUdpSocket.ReadOperation.buffer

null

Internal read buffer.

Network.AsyncUdpSocket.ReadOperation.check

def (self, result)

Checks for the operation completion. The operation succeed if data is available and the completion predicate returns true for the current read buffer. It fails on error.

Network.AsyncUdpSocket.ReadOperation.completion

null

Internal combination condition.

Network.AsyncUdpSocket.ReadOperation.g_lib

lib ('libmint-network')

Global library handle.

Network.AsyncUdpSocket.ReadOperation.get

def (self)

Returns the received data as an instance of Serializer.DataStream.

Network.AsyncUdpSocket.ReadOperation.new

def (self, socket)

Creates a new asynchronous operation to read data from socket until the completion predicate returns true.

The completion parameter is a function that receives the current receive buffer and returns true when the operation should complete.

Network.AsyncUdpSocket.ReadOperation.setup

def (self, scheduler)

Network.AsyncUdpSocket.ReadOperation.socket

null

Internal socket.

Network.AsyncUdpSocket.WriteOperation.buffer

null

Internal write buffer.

Network.AsyncUdpSocket.WriteOperation.check

def (self, result)

Checks for the operation completion. The operation succeed if all the data in the buffer is sent. It fails on error.

Network.AsyncUdpSocket.WriteOperation.count

0

Internal sent byte counter.

Network.AsyncUdpSocket.WriteOperation.g_lib

lib ('libmint-network')

Global library handle.

Network.AsyncUdpSocket.WriteOperation.get

def (self)

Returns an iterator containing true and the amount of sent data in bytes if the data was successfully sent to the peer; otherwise returns false.

Network.AsyncUdpSocket.WriteOperation.new

def (self, socket, buffer)

Creates a new asynchronous operation to send the data provided by buffer to socket.

Network.AsyncUdpSocket.WriteOperation.setup

def (self, scheduler)

Network.AsyncUdpSocket.WriteOperation.socket

null

Internal socket.

Network.AsyncUdpSocket.WriteOperation.status

false

Internal write status.

Network.AsyncUdpSocket.WriteToOperation.buffer

null

Internal write buffer.

Network.AsyncUdpSocket.WriteToOperation.check

def (self, result)

Checks for the operation completion. The operation succeed if all the data in the buffer is sent. It fails on error.

Network.AsyncUdpSocket.WriteToOperation.count

0

Internal sent byte counter.

Network.AsyncUdpSocket.WriteToOperation.endpoint

null

Internal peer endpoint.

Network.AsyncUdpSocket.WriteToOperation.g_lib

lib ('libmint-network')

Global library handle.

Network.AsyncUdpSocket.WriteToOperation.get

def (self)

Returns an iterator containing true and the amount of sent data in bytes if the data was successfully sent to the peer; otherwise returns false.

Network.AsyncUdpSocket.WriteToOperation.new

def (self, socket, endpoint, buffer)

Creates a new asynchronous operation to send the data provided by buffer to the peer accessible with the IP address descibed by address and the UDP port descibed by port using socket.

Network.AsyncUdpSocket.WriteToOperation.setup

def (self, scheduler)

Network.AsyncUdpSocket.WriteToOperation.socket

null

Internal socket.

Network.AsyncUdpSocket.WriteToOperation.status

false

Internal write status.

Network.AsyncUdpSocket.bind

def (self, endpoint)

Tells the socket to listen for incoming messages from endpoint. Returns true on success; otherwise returns false.

An instance of Exception.SocketError is raised on error.

Network.AsyncUdpSocket.connect

def (self, endpoint)

Attempts to make a connection to the device identified by the endpoint parameter. Returns true if connection succeed or if the connection request was successfully sent and is waiting for acknowledgment; otherwise returns false.

An instance of Exception.SocketError is raised on error.

Network.AsyncUdpSocket.g_lib

lib ('libmint-network')

Global library handle.

Network.AsyncUdpSocket.open

def (self, ipVersion)

Attempts to open the socket without connection to the remote device. The socket is open using the ipVersion version of the IP protocol. Returns true if the socket was correctly opened; otherwise returns false.

An instance of Exception.SocketError is raised on error.

Network.AsyncUdpSocket.read

def (self)

Returns all available data received from the peer as an instance of Serializer.DataStream or none if no data is available.

An instance of Exception.SocketError is raised on error.

Network.AsyncUdpSocket.readFrom

def (self)

Asynchronously receives a data from any peer.

The operation suspends the current coroutine until new data becomes available.

Returns the received data as an instance of Serializer.DataStream and an instance of Network.UdpSocket initialized (but not connected) with the informations of that peer. This endpoint can be used to open a dedicated channel with that peer.

An instance of Exception.SocketError is raised on error.

Network.AsyncUdpSocket.write

def (self, data)

Sends the data described by the data parameter to the peer. The data parameter must be an instance of Serializer.DataStream. Returns an iterator containing true and the amount of sent data in bytes if the data was successfully sent to the peer; otherwise returns false.

An instance of Exception.SocketError is raised on error.

Network.AsyncUdpSocket.writeTo

def (self, endpoint, data)

Asynchronously sends the data described by the data parameter to the peer described by endpoint.

The data parameter must be an instance of Serializer.DataStream.

The operation suspends the current coroutine until all bytes have been written or an error occurs. Partial writes may occur internally and the operation will continue sending the remaining data until the buffer is empty.

Returns an iterator containing true and the amount of sent data in bytes if the data was successfully sent to the peer; otherwise returns false.

The endpoint must be in the Network.Socket.State.Bound state.

An instance of Exception.SocketError is raised on error.

Network.UdpSocket.asyncOn

def (self, scheduler)

Returns a new instance of Network.AsyncUdpSocket initialized with the current socket and the scheduler parameter.

Network.UdpSocket.bind

def (self, endpoint)

Tells the socket to listen for incoming messages from endpoint. Returns true on success; otherwise returns false.

An instance of Exception.SocketError is raised on error.

Network.UdpSocket.connect

def (self, endpoint)

Attempts to make a connection to the device identified by the endpoint parameter. Returns true if connection succeed or if the connection request was successfully sent and is waiting for acknowledgment; otherwise returns false.

An instance of Exception.SocketError is raised on error.

Network.UdpSocket.g_lib

lib ('libmint-network')

Global library handle.

Network.UdpSocket.open

def (self, ipVersion)

Attempts to open the socket without connection to the remote device. The socket is open using the ipVersion version of the IP protocol. Returns true if the socket was correctly opened; otherwise returns false.

An instance of Exception.SocketError is raised on error.

Network.UdpSocket.read

def (self)

Returns all available data received from the peer as an instance of Serializer.DataStream or none if no data is available.

An instance of Exception.SocketError is raised on error.

Network.UdpSocket.readFrom

def (self)

Returns an iterator containing the available data received from any peer as an instance of Serializer.DataStream and an instance of Network.UdpSocket initialized (but not connected) with the informations of that peer. This endpoint can be used to open a dedicated channel with that peer. Returns none if no data is available.

An instance of Exception.SocketError is raised on error.

Network.UdpSocket.write

def (self, data)

Sends the data described by the data parameter to the peer. The data parameter must be an instance of Serializer.DataStream. Returns an iterator containing true and the amount of sent data in bytes if the data was successfully sent to the peer; otherwise returns false.

An instance of Exception.SocketError is raised on error.

Network.UdpSocket.writeTo

def (self, endpoint, data)

Sends the data described by the data parameter to the peer described by endpoint. The data parameter must be an instance of Serializer.DataStream. Returns an iterator containing true and the amount of sent data in bytes if the data was successfully sent to the peer; otherwise returns false.

An instance of Exception.SocketError is raised on error.