57 {
if ((
FD = myNet.
Relay(dest)) < 0)
58 {
eDest->Emsg(
"NetMsg",
"Unable to create UDP msg socket.");
70 const char *eText = specDest.
Set(dest);
72 {
eDest->Emsg(
"NetMsg",
"Default", dest,
"is unreachable");
73 if (aOK) *aOK =
false;
82 {
eDest->Emsg(
"NetMsg",
"Unable to create UDP msg socket.");
83 if (aOK) *aOK =
false;
133 if (!Blen && !(Blen = strlen(Buff)))
return 0;
140 {
eDest->Emsg(
"NetMsg",
"Destination not specified.");
return -1;}
145 }
while (retc < 0 && errno == EINTR);
154 if (specDest.
Set(dest))
155 {
eDest->Emsg(
"NetMsg", dest,
"is unreachable");
return -1;}
157 if (tmo >= 0 && !
OK2Send(tmo, dest))
return 1;
161 while (retc < 0 && errno == EINTR);
163 return (retc < 0 ?
retErr(errno, specDest) : 0);
169 const char *Buff,
int Blen,
int tmo)
173 if (!Blen && !(Blen = strlen(Buff)))
return 0;
175 if (netSA.
Addr.sa_family == AF_INET) aSize =
sizeof(netSA.
v4);
176 else if (netSA.
Addr.sa_family == AF_INET6) aSize =
sizeof(netSA.
v6);
177 else return retErr(EAFNOSUPPORT, (dest ? dest :
"Unknown!"));
179 if (tmo >= 0 && !
OK2Send(tmo, dest))
return 1;
182 while (retc < 0 && errno == EINTR);
184 if (retc >= 0)
return 0;
185 return retErr(errno, (dest ? dest :
"Unknown!"));
191 const char *dest,
int tmo)
198 {
eDest->Emsg(
"NetMsg",
"Destination not specified.");
return -1;}
209 if (specDest.
Set(dest))
210 {
eDest->Emsg(
"NetMsg", dest,
"is unreachable");
return -1;}
214 struct msghdr mHdr{};
216 mHdr.msg_name = (
void*)specDest.
SockAddr();
217 mHdr.msg_namelen = specDest.
SockSize();
218 mHdr.msg_iov =
const_cast<struct iovec*
>(
iov);
219 mHdr.msg_iovlen = iovcnt;
223 if (tmo >= 0 && !
OK2Send(tmo, dest))
return 1;
227 do {retc = sendmsg(
FD, &mHdr, 0);}
while (retc < 0 && errno == EINTR);
231 return (retc < 0 ?
retErr(errno, specDest) : 0);
243 struct pollfd polltab = {
FD, POLLOUT|POLLWRNORM, 0};
246 do {retc = poll(&polltab, 1, timeout);}
while(retc < 0 && errno == EINTR);
248 if (retc == 0 || !(polltab.revents & (POLLOUT | POLLWRNORM)))
249 eDest->Emsg(
"NetMsg",
"UDP link to", dest,
"is blocked.");
251 eDest->Emsg(
"NetMsg",errno,
"poll", dest);
264 {
eDest->Emsg(
"NetMsg",
"Destination not specified.");
return -1;}
267 eDest->Emsg(
"NetMsg", ecode,
"send to", theDest);
268 return (EWOULDBLOCK == ecode || EAGAIN == ecode ? 1 : -1);
273 return retErr(ecode, theDest.
Name(
"unknown"));
const sockaddr * SockAddr()
const char * Name(const char *eName=0, const char **eText=0)
const char * Set(const char *hSpec, int pNum=PortInSpec)
int retErr(int ecode, const char *theDest)
int Send(const char *buff, int blen=0, const char *dest=0, int tmo=-1)
XrdNetMsg(XrdSysError *erp, const char *dest=0, bool *aOK=0, bool refr=false)
int OK2Send(int timeout, const char *dest)
static bool Register(XrdNetPeer &Peer)
static void UnRegister(int fd)
int Relay(XrdNetPeer &Peer, const char *dest, int opts=0)