ApertureOS
Data Structures | Typedefs | Enumerations | Functions
Socket API

Data Structures

struct  SocketDesc
 The description of the socket. More...
 
struct  SocketConnectionDesc
 The description of the socket connection. More...
 

Typedefs

typedef uint32_t(* Sock_ReadAsync) (uint8_t *buffer, uint32_t size)
 A pointer to a function that asynchronously performs a Socket read. More...
 
typedef uint32_t(* Sock_SeekAsync) (uint64_t offset, int whence)
 A pointer to a function that asynchronously performs a Socket seek. More...
 
typedef uint32_t(* Sock_WriteAsync) (uint8_t *src_buf, uint32_t size)
 A pointer to a function that asynchronously performs a Socket write. More...
 

Enumerations

enum  SOCK_ERROR {
  SOCK_ERROR_NONE = 0, SOCK_ERROR_UNKNOWN = 1 << 0, SOCK_ERROR_NO_FREE_CONNECTIONS = 1 << 1, SOCK_ERROR_NO_PERMS = 1 << 2,
  SOCK_ERROR_FAILED_BUSY = 1 << 3, SOCK_ERROR_EXISTS = 1 << 4, SOCK_ERROR_NOT_EXIST = 1 << 5
}
 Socket errors. More...
 
enum  SOCK_FEATURES {
  SOCK_FEAT_NONE = 0, SOCK_FEAT_WRITABLE = 1, SOCK_FEAT_READABLE = 2, SOCK_FEAT_SEEKABLE = 4,
  SOCK_FEAT_NOTIFICATION = 8, SOCK_FEAT_SUPERVISOR = 32
}
 Socket features. More...
 
enum  SOCK_NOTIFICATIONS {
  SOCK_NOTIFICATIONS_NONE = 0, SOCK_NOTIFICATION_WRITE = 1<<0, SOCK_NOTIFICATION_READ = 1<<1, SOCK_NOTIFICATION_SEEK = 1<<2,
  SOCK_NOTIFICATION_CONNECT = 1<<3, SOCK_NOTIFICATION_DISCONNECT = 1<<4, SOCK_NOTIFICATION_COMPLETE = 1 << 31
}
 Socket notifications. More...
 

Functions

SOCK_ERROR Socket_Create (const char *name, SocketDesc *desc)
 Create a new Socket and register it to the kernel. More...
 
SOCK_ERROR Socket_Connect (const char *name, SocketConnectionDesc *desc, UID *id)
 Attempt to connect to a socket. More...
 
SOCK_ERROR Socket_Disconnect (UID id)
 Attempt to disconnect from the socket. More...
 
SOCK_ERROR Socket_ReadAsync (UID id, uint8_t *buffer, uint32_t size)
 Request an asynchronous read from the socket. More...
 
SOCK_ERROR Socket_WriteAsync (UID id, uint8_t *buffer, uint32_t size)
 Request an asynchronous write to the socket. More...
 
SOCK_ERROR Socket_SeekAsync (UID id, uint64_t offset, int whence)
 Request an asynchronous seek of the socket. More...
 

Detailed Description

Typedef Documentation

typedef uint32_t(* Sock_ReadAsync) (uint8_t *buffer, uint32_t size)

A pointer to a function that asynchronously performs a Socket read.

typedef uint32_t(* Sock_SeekAsync) (uint64_t offset, int whence)

A pointer to a function that asynchronously performs a Socket seek.

typedef uint32_t(* Sock_WriteAsync) (uint8_t *src_buf, uint32_t size)

A pointer to a function that asynchronously performs a Socket write.

Enumeration Type Documentation

enum SOCK_ERROR

Socket errors.

Enumerator
SOCK_ERROR_NONE 

No error.

SOCK_ERROR_UNKNOWN 

Unknown error.

SOCK_ERROR_NO_FREE_CONNECTIONS 

There are no free connections on this socket.

SOCK_ERROR_NO_PERMS 

The calling thread doesn't have the permissions.

SOCK_ERROR_FAILED_BUSY 

The socket is busy.

SOCK_ERROR_EXISTS 

The socket already exists.

SOCK_ERROR_NOT_EXIST 

The socket does not exist.

Socket features.

Enumerator
SOCK_FEAT_NONE 

No features.

SOCK_FEAT_WRITABLE 

Socket can be written to.

SOCK_FEAT_READABLE 

Socket may be read from.

SOCK_FEAT_SEEKABLE 

Socket is seekable.

SOCK_FEAT_NOTIFICATION 

Socket can send notifications into the message pump.

SOCK_FEAT_SUPERVISOR 

Request supervisor level access.

Socket notifications.

Enumerator
SOCK_NOTIFICATIONS_NONE 

Send no notifications.

SOCK_NOTIFICATION_WRITE 

Send notification on write.

SOCK_NOTIFICATION_READ 

Send notification on read.

SOCK_NOTIFICATION_SEEK 

Send notification on seek.

SOCK_NOTIFICATION_CONNECT 

Send notification on connect.

SOCK_NOTIFICATION_DISCONNECT 

Send notification on disconnect.

SOCK_NOTIFICATION_COMPLETE 

Signals the completion of an asynchronous action for the current thread.

Function Documentation

SOCK_ERROR Socket_Connect ( const char *  name,
SocketConnectionDesc desc,
UID id 
)

Attempt to connect to a socket.

Parameters
nameThe name of the socket to connect to
descThe description of the requested connection
idThe UID identifying the connection
Returns
An error code describing the result of the operation
See also
SOCK_ERROR, Socket_Disconnect()
SOCK_ERROR Socket_Create ( const char *  name,
SocketDesc desc 
)

Create a new Socket and register it to the kernel.

Parameters
nameThe name of the socket
descThe description of the socket
Returns
An error code describing the result of the operation
See also
SOCK_ERROR
SOCK_ERROR Socket_Disconnect ( UID  id)

Attempt to disconnect from the socket.

Note: Disconnection may fail if the socket is busy

Parameters
idThe UID identifying the connection
Returns
An error code describing the result of the operation
See also
Socket_Connect(), SOCK_ERROR
SOCK_ERROR Socket_ReadAsync ( UID  id,
uint8_t *  buffer,
uint32_t  size 
)

Request an asynchronous read from the socket.

The socket is required to notify through the message pump with the SOCK_NOTIFICATION_COMPLETE flag set on completion of this request. This operation requires the socket to support reading and the connection to have requested permission to do so

Parameters
idThe UID identifying the connection
bufferThe buffer to write the read data to
sizeThe size in bytes of data to read
Returns
An error code describing the result of the operation
See also
Socket_WriteAsync(), Socket_SeekAsync(), SOCK_NOTIFICATIONS
SOCK_ERROR Socket_SeekAsync ( UID  id,
uint64_t  offset,
int  whence 
)

Request an asynchronous seek of the socket.

The socket is required to notify through the message pump with the SOCK_NOTIFICATION_COMPLETE flag set on completion of this request. This operation requires the socket to support seeking and the connection to have requested permission to do so

Parameters
idThe UID identifying the connection
offsetThe offset relative to whence to seek to
whenceThe location relative to which to seek
Returns
An error code describing the result of the operation
See also
Socket_ReadAsync(), Socket_WriteAsync(), SOCK_NOTIFICATIONS
SOCK_ERROR Socket_WriteAsync ( UID  id,
uint8_t *  buffer,
uint32_t  size 
)

Request an asynchronous write to the socket.

The socket is required to notify through the message pump with the SOCK_NOTIFICATION_COMPLETE flag set on completion of this request. This operation requires the socket to support writing and the connection to have requested permission to do so

Parameters
idThe UID identifying the connection
bufferThe buffer to read the data to write from
sizeThe size in bytes of data to write
Returns
An error code describing the result of the operation
See also
Socket_ReadAsync(), Socket_SeekAsync(), SOCK_NOTIFICATIONS