Xsend(), Xsendto() - - send a message on a socket.
More...
#include "Xsocket.h"
#include "Xinit.h"
#include "Xutil.h"
#include "errno.h"
#include "dagaddr.hpp"
|
| #define | fmsg "%s is not currently supported, clearing...\n" |
| |
|
| int | Xsend (int sockfd, const void *buf, size_t len, int flags) |
| | Send a message on an Xsocket. More...
|
| |
| int | Xsendto (int sockfd, const void *buf, size_t len, int flags, const struct sockaddr *addr, socklen_t addrlen) |
| | Sends a datagram message on an Xsocket. More...
|
| |
| #define fmsg "%s is not currently supported, clearing...\n" |
| int Xsend |
( |
int |
sockfd, |
|
|
const void * |
buf, |
|
|
size_t |
len, |
|
|
int |
flags |
|
) |
| |
The Xsend() call may be used only when the socket is in a connected state (so that the intended recipient is known). It only works with an Xsocket of type XSOCK_STREAM that has previously been connecteted with Xaccept() or Xconnect().
- Parameters
-
| sockfd | The socket to send the data on |
| buf | the data to send |
| len | length of the data to send. Currently the Xsend api is limited to sending at most XIA_MAXBUF bytes. |
| flags | (This is not currently used but is kept to be compatible with the standard sendto socket call. |
- Returns
- number of bytes sent on success
-
-1 on failure with errno set to an error compatible with those returned by the standard send call.
| int Xsendto |
( |
int |
sockfd, |
|
|
const void * |
buf, |
|
|
size_t |
len, |
|
|
int |
flags, |
|
|
const struct sockaddr * |
addr, |
|
|
socklen_t |
addrlen |
|
) |
| |
Xsendto sends a datagram to the specified address. The final intent of the address should be a valid SID.
Unlike a standard socket, Xsendto() is only valid on Xsockets of type XSOCK_DGRAM.
If the buffer is too large, Xsendto() will truncate the message and send what it can. This is different from the standard sendto which returns an error.
- Parameters
-
| sockfd | The socket to send the data on |
| buf | the data to send |
| len | lenngth of the data to send. The Xsendto api is limited to sending at most XIA_MAXBUF bytes. |
| flags | (This is not currently used but is kept to be compatible with the standard sendto socket call. |
| addr | address (SID) to send the datagram to |
| addrlen | length of the DAG |
- Returns
- number of bytes sent on success
-
-1 on failure with errno set to an error compatible with those returned by the standard sendto call.