#include <sys/socket.h>
#include <netinet/in.h>
#include <unistd.h>
Go to the source code of this file.
|
| NvPSFSocketStatus | NvPSFSocketCreate (int domain, NvPSFSocketType type, NvPSFSocketEndpoint role, NvPSFSocketBlockingMode blocking) |
| | Create a new socket with specified parameters. More...
|
| |
| NvPSFSocketStatus | NvPSFSocketBind (int sockfd, const struct sockaddr *addr, socklen_t addrlen) |
| | Bind a socket to a local address. More...
|
| |
| NvPSFSocketStatus | NvPSFSocketListen (int sockfd) |
| | Start listening for incoming connections. More...
|
| |
| NvPSFSocketStatus | NvPSFSocketAccept (int sockfd, struct sockaddr *addr, socklen_t *addrlen) |
| | Accept an incoming connection. More...
|
| |
| NvPSFSocketStatus | NvPSFSocketConnect (int sockfd, const struct sockaddr *addr, socklen_t addrlen) |
| | Connect to a remote socket. More...
|
| |
| NvPSFSocketStatus | NvPSFSocketSend (int sockfd, const void *buf, size_t len, int flags) |
| | Send data through a socket. More...
|
| |
| NvPSFSocketStatus | NvPSFSocketReceive (int sockfd, void *buf, size_t len, int flags) |
| | Receive data from a socket. More...
|
| |
| NvPSFSocketStatus | NvPSFSocketClose (int sockfd) |
| | Close a socket descriptor. More...
|
| |
◆ MAX_PENDING_CONNECTIONS
| #define MAX_PENDING_CONNECTIONS 10 |
Maximum number of pending connections in listen queue.
◆ SOCKET_BUFFER_SIZE
| #define SOCKET_BUFFER_SIZE 4096 |
Default buffer size for socket operations.
◆ SOCKET_PERMISSIONS
| #define SOCKET_PERMISSIONS 0660 |
Default permissions for socket files (when applicable)
◆ NvPSFSocketBlockingMode
| Enumerator |
|---|
| SOCK_BLOCKING | Blocking mode
|
| SOCK_NON_BLOCKING | Non-blocking mode
|
NvPSFSocketBlockingMode
Definition: posix_socket_comms.h:75
@ SOCK_BLOCKING
Definition: posix_socket_comms.h:76
@ SOCK_NON_BLOCKING
Definition: posix_socket_comms.h:77
◆ NvPSFSocketEndpoint
| Enumerator |
|---|
| SOCKET_SERVER | Socket acting as server
|
| SOCKET_CLIENT | Socket acting as client
|
| SOCKET_BIDIRECTIONAL | Socket used for bidirectional communication
|
NvPSFSocketEndpoint
Definition: posix_socket_comms.h:65
@ SOCKET_BIDIRECTIONAL
Definition: posix_socket_comms.h:68
@ SOCKET_SERVER
Definition: posix_socket_comms.h:66
@ SOCKET_CLIENT
Definition: posix_socket_comms.h:67
◆ NvPSFSocketErr
| Enumerator |
|---|
| NvPSFSOCK_SUCCESS | Operation successful
|
| NvPSFSOCK_FAIL | Operation failed
|
NvPSFSocketErr
Definition: posix_socket_comms.h:84
@ NvPSFSOCK_FAIL
Definition: posix_socket_comms.h:86
@ NvPSFSOCK_SUCCESS
Definition: posix_socket_comms.h:85
◆ NvPSFSocketType
| Enumerator |
|---|
| SOCK_STREAM_TYPE | Stream socket (TCP)
|
| SOCK_DGRAM_TYPE | Datagram socket (UDP)
|
NvPSFSocketType
Definition: posix_socket_comms.h:56
@ SOCK_DGRAM_TYPE
Definition: posix_socket_comms.h:58
@ SOCK_STREAM_TYPE
Definition: posix_socket_comms.h:57
◆ NvPSFSocketAccept()
| NvPSFSocketStatus NvPSFSocketAccept |
( |
int |
sockfd, |
|
|
struct sockaddr * |
addr, |
|
|
socklen_t * |
addrlen |
|
) |
| |
Accept an incoming connection.
- Parameters
-
| sockfd | Listening socket descriptor |
| addr | Pointer to store client address (optional) |
| addrlen | Pointer to store client address length (optional) |
- Returns
- Status structure containing:
- New socket descriptor in retCode.sockfd on success
- Error code in retCode.errCode on failure
◆ NvPSFSocketBind()
| NvPSFSocketStatus NvPSFSocketBind |
( |
int |
sockfd, |
|
|
const struct sockaddr * |
addr, |
|
|
socklen_t |
addrlen |
|
) |
| |
Bind a socket to a local address.
- Parameters
-
| sockfd | Socket descriptor to bind |
| addr | Pointer to sockaddr structure containing address information |
| addrlen | Length of the address structure |
- Returns
- Status structure with operation result
◆ NvPSFSocketClose()
Close a socket descriptor.
- Parameters
-
| sockfd | Socket descriptor to close |
- Returns
- Status structure with operation result
◆ NvPSFSocketConnect()
| NvPSFSocketStatus NvPSFSocketConnect |
( |
int |
sockfd, |
|
|
const struct sockaddr * |
addr, |
|
|
socklen_t |
addrlen |
|
) |
| |
Connect to a remote socket.
- Parameters
-
| sockfd | Socket descriptor to use for connection |
| addr | Pointer to sockaddr structure with target address |
| addrlen | Length of the address structure |
- Returns
- Status structure with operation result
◆ NvPSFSocketCreate()
Create a new socket with specified parameters.
- Parameters
-
| domain | The protocol family (e.g., AF_INET, AF_INET6) |
| type | The socket type (SOCK_STREAM_TYPE or SOCK_DGRAM_TYPE) |
| role | The role determining default configurations (server/client/bidirectional) |
| blocking | Whether the socket should operate in blocking or non-blocking mode |
- Returns
- Status structure containing:
- Socket descriptor in retCode.sockfd on success
- Error code in retCode.errCode on failure
◆ NvPSFSocketListen()
Start listening for incoming connections.
- Parameters
-
| sockfd | Socket descriptor to listen on |
- Returns
- Status structure with operation result
◆ NvPSFSocketReceive()
| NvPSFSocketStatus NvPSFSocketReceive |
( |
int |
sockfd, |
|
|
void * |
buf, |
|
|
size_t |
len, |
|
|
int |
flags |
|
) |
| |
Receive data from a socket.
- Parameters
-
| sockfd | Connected socket descriptor |
| buf | Pointer to receive buffer |
| len | Maximum length to receive |
| flags | Additional receive flags |
- Returns
- Status structure containing:
- Number of bytes received in retCode.bytesTransferred on success
- Error code in retCode.errCode on failure
◆ NvPSFSocketSend()
| NvPSFSocketStatus NvPSFSocketSend |
( |
int |
sockfd, |
|
|
const void * |
buf, |
|
|
size_t |
len, |
|
|
int |
flags |
|
) |
| |
Send data through a socket.
- Parameters
-
| sockfd | Connected socket descriptor |
| buf | Pointer to data buffer |
| len | Length of data to send |
| flags | Additional send flags |
- Returns
- Status structure containing:
- Number of bytes sent in retCode.bytesTransferred on success
- Error code in retCode.errCode on failure