|
Open Model Railroad Network (OpenMRN)
|
#include <cstdlib>#include <cstdint>#include <sys/socket.h>#include <sys/stat.h>#include "Devtab.hxx"#include "Socket.hxx"#include "can_ioctl.h"Go to the source code of this file.
Functions | |
| int | socket (int domain, int type, int protocol) |
| Create an unbound socket in a communications domain. | |
| int | bind (int socket, const struct sockaddr *address, socklen_t address_len) |
| Bind a name to a socket. | |
| int | listen (int socket, int backlog) |
| Mark a connection-mode socket, specified by the socket argument, as accepting connections. | |
| int | accept (int socket, struct sockaddr *address, socklen_t *address_len) |
| Accept a new connection on a socket. | |
| int | connect (int socket, const struct sockaddr *address, socklen_t address_len) |
| Connect a socket. | |
| ssize_t | recv (int socket, void *buffer, size_t length, int flags) |
| Receive a message from a connection-mode or connectionless-mode socket. | |
| ssize_t | send (int socket, const void *buffer, size_t length, int flags) |
| Initiate transmission of a message from the specified socket. | |
| int | setsockopt (int socket, int level, int option_name, const void *option_value, socklen_t option_len) |
| Set the socket options. | |
| int | getsockopt (int socket, int level, int option_name, void *option_value, socklen_t *option_len) |
| Get the socket options. | |
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This file implements a generic socket device driver layer.
Definition in file Socket.cxx.
Accept a new connection on a socket.
| socket | the socket file descriptor |
| address | either a null pointer, or a pointer to a sockaddr structure where the address of the connecting socket shall be returned |
| address_len | either a null pointer, if address is a null pointer, or a pointer to a socklen_t object which on input specifies the length of the supplied sockaddr structure, and on output specifies the length of the stored address |
Definition at line 194 of file Socket.cxx.
Bind a name to a socket.
| socket | file descriptor of the socket to be bound |
| address | points to a sockaddr structure containing the address to be bound to the socket |
| address_len | specifies the length of the sockaddr structure pointed to by the address argument |
Definition at line 159 of file Socket.cxx.
Connect a socket.
| socket | the socket file descriptor |
| address | points to a sockaddr structure containing the peer address |
| address_len | specifies the length of the sockaddr structure pointed to by the address argument |
Definition at line 208 of file Socket.cxx.
| int getsockopt | ( | int | socket, |
| int | level, | ||
| int | option_name, | ||
| void * | option_value, | ||
| socklen_t * | option_len | ||
| ) |
Get the socket options.
| socket | the socket file descriptor |
| level | specifies the protocol level at which the option resides |
| option_name | specifies a single option to get |
| option_value | the metadata that belongs to the option_name |
| option_len | the length of the metadata that belongs to the option_name |
Definition at line 272 of file Socket.cxx.
| int listen | ( | int | socket, |
| int | backlog | ||
| ) |
Mark a connection-mode socket, specified by the socket argument, as accepting connections.
| socket | the socket file descriptor |
| backlog | provides a hint to the implementation which the implementation shall use to limit the number of outstanding connections in the socket's listen queue |
Definition at line 174 of file Socket.cxx.
| ssize_t recv | ( | int | socket, |
| void * | buffer, | ||
| size_t | length, | ||
| int | flags | ||
| ) |
Receive a message from a connection-mode or connectionless-mode socket.
| socket | the socket file descriptor |
| buffer | buffer where the message should be stored |
| length | length in bytes of the buffer pointed to by the buffer argument |
| flags | Specifies the type of message reception |
Definition at line 225 of file Socket.cxx.
| ssize_t send | ( | int | socket, |
| const void * | buffer, | ||
| size_t | length, | ||
| int | flags | ||
| ) |
Initiate transmission of a message from the specified socket.
| socket | the socket file descriptor |
| buffer | buffer containing the message to send |
| length | length of the message in bytes |
| flags | the type of message transmission |
Definition at line 239 of file Socket.cxx.
| int setsockopt | ( | int | socket, |
| int | level, | ||
| int | option_name, | ||
| const void * | option_value, | ||
| socklen_t | option_len | ||
| ) |
Set the socket options.
| socket | the socket file descriptor |
| level | specifies the protocol level at which the option resides |
| option_name | specifies a single option to set |
| option_value | the metadata that belongs to the option_name |
| option_len | the length of the metadata that belongs to the option_name |
Definition at line 255 of file Socket.cxx.
| int socket | ( | int | domain, |
| int | type, | ||
| int | protocol | ||
| ) |
Create an unbound socket in a communications domain.
| domain | specifies the communications domain in which a socket is to be created |
| type | specifies the type of socket to be created |
| protocol | specifies a particular protocol to be used with the socket, specifying a protocol of 0 causes socket() to use an unspecified default protocol appropriate for the requested socket type |
Definition at line 144 of file Socket.cxx.