MasterScan  Lab_Matlab_control Master Branch
List of all members | Properties and Events
dotsAllSocketObjects Class Reference

Overview

An abstract interface for working with sockets.

dotsAllSocketObjects defines a standard interface for working with network sockets in Snow Dots. Subclasses of dotsAllSocketObjects are expected to implement a set methods that accomplish socket behaviors. These may be wrappers around mex function calls, for example.

The purpose of the dotsAllSocketObjects interface is to allow Snow Dots to run on any Matlab platform that has a native sockets implementation. Each dotsAllSocketObjects subclass must encapsulate the details of the sockets implementation.

Depending on how socket behaviors are implemented, a subclass may need to define properties, or it may store data with a mex function or elsewhere. Thus, properties are not expected as part of the dotsAllSocketObjects interface.

Any Snow Dots function that wants to use network sockets should create an instance of a dotsAllSocketObjects class that is appropriate for the local machine. The machine-appropriate class should be specified in dotsTheMachineConfiguration, as the default "socketClassName". This value can be accessed through dotsTheMachineConfiguration. For example:

mySocketObject = feval(name);
Inheritance diagram for dotsAllSocketObjects:
Inheritance graph
[legend]

Properties and Events

null id = open(self, localIP, localPort, remoteIP, remotePort)
 Open a new socket and return an identifier for it. More...
 
null status = close(self, id)
 Close an open socket. More...
 
null hasData = check(self, id, timeoutSecs)
 Check whether a socket has a packet to read. More...
 
null data = readBytes(self, id)
 Read byte data from a socket. More...
 

Properties and Events

◆ id

null id = open(self, localIP, localPort, remoteIP, remotePort)

Open a new socket and return an identifier for it.

Parameters
localIPstring IP address to bind on this host
localPortport number to bind on this host
remoteIPstring IP address to connect to
remotePortport number to connect to

Must open an new socket to communicate between the host at localIP:localPort and remoteIP:remotePort.

Must return a nonnegative scalar identifier for the new socket, or a negative scalar to indicate an error.

◆ status

null status = close(self, id)

Close an open socket.

Write byte data to a socket.

Close all open sockets.

Parameters
ida socket identifier as returned from open()

Must close a previosuly opened socket and free resources as needed.

Must return a nonnegative scalar, or a negative scalar to indicate an error.

Must close all sockets that were opened with open() and free all socket resources.

Must return a nonnegative scalar, or a negative scalar to indicate an error.

Parameters
ida socket identifier as returned from open()
dataan array of data to send

Must send data from the @id socket to its connected remote host. data might have any type, but should be treated here as an array of uint8 (single bytes).

For UDP sockets, write() should write the contents of data to a single packet and send it immediately.

Must return a nonnegative scalar, or a negative scalar to indicate an error. Must not block.

◆ hasData

null hasData = check(self, id, timeoutSecs)

Check whether a socket has a packet to read.

Parameters
ida socket identifier as returned from open()
timeoutSecsoptional time to wait for a packet

Must return true if the id socket has a data ready to read, or false if it has none. if timeoutSecs is provided, may block, waiting for a packet for that many seconds. Otherwise, must not block.

check() must leave any available packet in place, to be consumed during the next read().

◆ data

null data = readBytes(self, id)

Read byte data from a socket.

Parameters
ida socket identifier as returned from open()

Must read, consume, and return data available at the @id socket. The data might have had any type initially, but should be treated here as an array of uint8 (single bytes).

For UDP sockets, readBytes() should consume one available packet buffered at the socket.

If the socket has no data, readBytes() shoud return an empty array immediately. Must not block.


The documentation for this class was generated from the following file: