53 else {
eDest->
Emsg(
"Msg",
"Default", dest,
"is unreachable");
58 if ((
FD = myNet.
Relay(dest)) < 0)
59 {
eDest->
Emsg(
"Msg",
"Unable to create UDP msg socket.");
75 if (!Blen && !(Blen = strlen(Buff)))
return 0;
79 {
eDest->
Emsg(
"Msg",
"Destination not specified.");
return -1;}
83 {
eDest->
Emsg(
"Msg", dest,
"is unreachable");
return -1;}
86 if (tmo >= 0 && !
OK2Send(tmo, dest))
return 1;
90 while (retc < 0 && errno == EINTR);
92 return (retc < 0 ?
retErr(errno, theDest) : 0);
98 const char *Buff,
int Blen,
int tmo)
102 if (!Blen && !(Blen = strlen(Buff)))
return 0;
104 if (netSA.
Addr.sa_family == AF_INET) aSize =
sizeof(netSA.
v4);
105 else if (netSA.
Addr.sa_family == AF_INET6) aSize =
sizeof(netSA.
v6);
108 if (tmo >= 0 && !
OK2Send(tmo, dest))
return 1;
111 while (retc < 0 && errno == EINTR);
113 if (retc >= 0)
return 1;
114 return (EWOULDBLOCK == errno || EAGAIN == errno ? 1 : -1);
120 const char *dest,
int tmo)
122 char buff[4096], *bp = buff;
123 int i, dsz =
sizeof(buff);
125 if (tmo >= 0 && !
OK2Send(tmo, dest))
return 1;
127 for (i = 0; i < iovcnt; i++)
128 {dsz -=
iov[i].iov_len;
129 if (dsz < 0)
return retErr(EMSGSIZE, dest);
130 memcpy((
void *)bp,(
const void *)
iov[i].iov_base,
iov[i].iov_len);
131 bp +=
iov[i].iov_len;
134 return Send(buff, (
int)(bp-buff), dest, -1);
146 struct pollfd polltab = {
FD, POLLOUT|POLLWRNORM, 0};
149 do {retc = poll(&polltab, 1, timeout);}
while(retc < 0 && errno == EINTR);
151 if (retc == 0 || !(polltab.revents & (POLLOUT | POLLWRNORM)))
152 eDest->
Emsg(
"Msg",
"UDP link to", dest,
"is blocked.");
167 {
eDest->
Emsg(
"Msg",
"Destination not specified.");
return -1;}
170 eDest->
Emsg(
"Msg", ecode,
"send to", theDest);
171 return (EWOULDBLOCK == ecode || EAGAIN == ecode ? 1 : -1);
176 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)
int OK2Send(int timeout, const char *dest)
XrdNetMsg(XrdSysError *erp, const char *dest=0, bool *aOK=0)
int Relay(XrdNetPeer &Peer, const char *dest, int opts=0)
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)