group
group__libshare__net
The libshare Socket Handling provides access to regular socket operations with posix or convienence functions in addition to access to the ESP network protocol.
Network socket operations.
The ESP protocol performs streaming compression and provides more security than TCP. The libshare network socket operations.
typedef struct shnet_t shnet_t
shnet_t _sk_table[65536]
[65536]
socket
int shnet_accept
(int sockfd)
accept
int shnet_bindsk
(int sockfd, char *hostname, unsigned int port)
bind
int shnet_bind
(int sockfd, const struct sockaddr *addr, socklen_t addrlen)
bind
int shnet_listen
(int sockfd, int backlog)
listen
int shnet_close
(int sk)
close
int shnet_conn
(int sk, char *host, unsigned short port, int async)
connect
int shnet_fcntl
(int fd, int cmd, long arg)
fcntl
struct hostent* shresolve
(char *hostname)
gethost
struct sockaddr* shaddr
(int sockfd)
getaddr
const char* shaddr_print
(struct sockaddr *addr)
getaddr
ssize_t shnet_read
(int fd, const void *buf, size_t count)
Reads or buffers data content from a socket.
Param
fd
The file descriptor opened with or .
shnet_sk()
group__libshare__net_1ga0762a18a7420961416ddd0677a151fca
member
shnet_socket()
group__libshare__net_1gae7937b44d1e895c738ba99e44c585494
member
buf
The buffer to write data into or NULL in order to buffer the information.
count
The maximum size of the data buffer.
Return Value
The number of bytes read, 0 when an asynchronous connection has no information to read, or a negative libshare error code.
Note
The error code SHERR_CONNRESET is returned when the remote peer naturally closes the socket connection.
int shnet_sk
(void)
Creates a standard IPv4 TCP socket.
int shnet_socket
(int domain, int type, int protocol)
Create a network socket.
Param
domain
Either AF_INET or AF_INET6.
type
Only SOCK_STREAM is supported.
protocol
Either IPPROTO_TCP or IPPROTO_SHNET.
struct sockaddr* shnet_host
(int sockfd)
socket
ssize_t shnet_write
(int fd, const void *buf, size_t count)
Write data content to a socket.
Param
fd
The file descriptor opened with or .
shnet_sk()
group__libshare__net_1ga0762a18a7420961416ddd0677a151fca
member
shnet_socket()
group__libshare__net_1gae7937b44d1e895c738ba99e44c585494
member
buf
The data content to be written.
count
The size of the data content.
Return Value
The number of bytes written or a libshare error code.
int shnet_write_flush
(int fd)
int shnet_verify
(fd_set *readfds, fd_set *writefds, long *millis)
Waits on the specified read/write socket streams and marks which are available for an IO operation.
See
shnet_select()
group__libshare__net_1ga064abd9c114957a942448ebdb6d07134
member
int shselect
(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout)
Performs a POSIX select() against a set of socket streams.
shnet_t
structshnet__t
compound
int shconnect
(int sk, struct sockaddr *skaddr, socklen_t skaddr_len)
Initiate a standard posix connection managable by libshare.
int shconnect_host
(char *host, unsigned short port, int flags)
* Initiate a connection to the hostname and port specified.
int shconnect_peer
(shpeer_t *peer, int flags)
* Initiate a socket connection to a libshare peer entity.
shbuf_t* shnet_read_buf
(int fd)
Obtain the internal socket buffer used for a network connection.
int shnet_write_buf
(int fd, unsigned char *data, size_t data_len)
shdb_t* shnet_track_open
(char *name)
Open the peer tracking database for the current application.
Param
A
specific database name or NULL for the default.
void shnet_track_close
(shdb_t *db)
Close a pre-opened peer tracking database.
int shnet_track_add
(shdb_t *db, shpeer_t *peer)
Adds a new peer entity to the track db.
int shnet_track_mark
(shdb_t *db, shpeer_t *peer, int cond)
int shnet_track_incr
(shdb_t *db, shpeer_t *peer)
int shnet_track_decr
(shdb_t *db, shpeer_t *peer)
int shnet_track_remove
(shdb_t *db, shpeer_t *peer)
int shnet_track_find
(shdb_t *db, shpeer_t *peer)
int shnet_track_count
(shdb_t *db, char *app_name)
shpeer_t** shnet_track_scan
(shdb_t *db, shpeer_t *peer, int list_max)
Provides a list of the oldest peer(s) marked for the service associated with the provided peer.
Param
db
The database to scan [from the network track table].
peer
The peer to search for a matching service.
Return Value
An allocated array of peers which needs to be freed via the "free()" call.
Note
A maximum of 1000 records is returned.
shpeer_t** shnet_track_list
(shdb_t *db, shpeer_t *peer, int list_max)
Provides a list of the most trusted peer(s).
Return Value
An allocated array of peers which needs to be freed via the "free()" call.
int shnet_track_verify
(shpeer_t *peer, int *sk_p)
Verify whether a network connect is accessible.
Param
sk_p
Must be set to zero on initial call.
int shnet_track_prune
(char *name)
Remove records that have more negative connections than positive.
Param
The
name of the "network tracking" database.
SHNET_ALIVE
(1 << 0)
socket is not closed
SHNET_CONNECT
(1 << 1)
perform asynchronous connection
SHNET_ASYNC
(1 << 2)
do not block client calls
SHNET_LISTEN
(1 << 3)
socket is bound to listen on port.
SHNET_SHUTDOWN
(1 << 5)
Automatically terminate socket after a successful connection.
SHNET_TRACK
(1 << 6)
Record connection fail/success in sharefs peer database.
SHNET_CRYPT
(1 << 7)
Socket communication is encrypted by the libshare API.
SHNET_HASH
(1 << 8)
Underlying protocol 'hashing' is performed by the libshare API.
SHNET_CERT
(1 << 9)
Access to socket communication is authorized by a certificate.
SHNET_DEFAULT_DEVICE
"eth0"
TX_NONE
0
A generic type referencing an invalid transaction.
TX_SUBSCRIBE
2
A transaction mode to request broadcasts of a transaction type.
Note
Only applicable for client message-queue communication.
TX_IDENT
3
A specfic application's reference to an account.
TX_ACCOUNT
4
An identifier of user credentials.
TX_SESSION
5
An active application session for an identity.
TX_APP
6
A libshare application identifier.
TX_FILE
7
A share-fs partition file transaction.
TX_WARD
8
A ward can be placed on another transaction to prohibit from being used.
TX_TRUST
9
A secondary confirmation of a transaction.
TX_LEDGER
10
A collection of transactions.
TX_LICENSE
11
A license granting access permission.
TX_METRIC
12
An account metric of identification.
TX_MEM
13
A memory pool transaction.
TX_VM
14
A task performing sexe execution thread(s).
TX_RUN
15
A sexe runtime execution thread.
TX_WALLET
16
A wallet owned by an identity.
TX_BOND
17
A virtual currency transaction.
TX_ASSET
18
"Anything tangible or intangible that can be owned or controlled to produce value and that is held to have positive economic value."
TX_CONTRACT
19
An agreement, or offer, to exchange two denominations of two assets.
TX_EVENT
20
An event specifies the duration of another transaction.
TX_EVAL
21
A negative or positive value for an identify in reference to a contextual event.
MAX_TX
25
The maximum number of transaction operations currently supported.
MAX_VERSION_TX
256
The maximum number of transaction operations ever supported.
TX_ASSET_DAEMON
11
A network service provider such as a web hosting daemon.
shnet_select
(shselect((_fd), (_readfd), (_writefd), (_excfd), (_to)))
A convience function for calling shselect.