XSocket API  2.0
XIA Socket Library
Macros | Functions
Xsend.c File Reference

Xsend(), Xsendto() - - send a message on a socket. More...

#include "Xsocket.h"
#include "Xinit.h"
#include "Xutil.h"
#include "errno.h"
#include "dagaddr.hpp"

Macros

#define fmsg   "%s is not currently supported, clearing...\n"
 

Functions

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...
 

Macro Definition Documentation

#define fmsg   "%s is not currently supported, clearing...\n"

Function Documentation

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
sockfdThe socket to send the data on
bufthe data to send
lenlength 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
sockfdThe socket to send the data on
bufthe data to send
lenlenngth 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.
addraddress (SID) to send the datagram to
addrlenlength 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.