Skip to content

Commit

Permalink
Tweaks to library
Browse files Browse the repository at this point in the history
  • Loading branch information
Ebenezer-group committed Sep 15, 2024
1 parent d259f53 commit e33fcce
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
16 changes: 6 additions & 10 deletions src/cmwBuffer.hh
Original file line number Diff line number Diff line change
Expand Up @@ -200,14 +200,6 @@ inline void setRcvTimeout (sockType s,int time){
if(setsockWrapper(s,SO_RCVTIMEO,t)!=0)raise("setRcvTimeout",getError());
}

inline int sockWrite (sockType s,void const* data,int len
,auto addr=nullptr,socklen_t toLen=0){
if(int r=::sendto(s,static_cast<char const*>(data),len,0,
reinterpret_cast<::sockaddr const*>(addr),toLen);r>0)
return r;
raise("sockWrite",s,getError());
}

inline int sockRead (sockType s,void* data,int len,sockaddr* addr,socklen_t* fromLen){
if(int r=::recvfrom(s,static_cast<char*>(data),len,0,addr,fromLen);r>=0)
return r;
Expand Down Expand Up @@ -431,8 +423,12 @@ template<class Z>class SendBuffer{
return false;
}

template<class T=int>void send (T* addr=nullptr,::socklen_t len=0)
{sockWrite(sock_,buf,index,addr,len);}
template<class T=int>auto send (T* addr=nullptr,::socklen_t len=0){
if(int r=::sendto(sock_,reinterpret_cast<char*>(buf),index,0,
reinterpret_cast<::sockaddr const*>(addr),len);r>0)
return r;
raise("sockWrite",sock_,getError());
}

#ifndef CMW_WINDOWS
void receiveFile (char const* n,::int32_t sz){
Expand Down
4 changes: 2 additions & 2 deletions src/tiers/cmwA.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ struct cmwRequest{
buf.receiveAt(idx,updatedFiles);
}

auto getFileName (){
auto fileName (){
Write(fl(),&bday,sizeof bday);
return path.append(".hh");
}
Expand Down Expand Up @@ -243,7 +243,7 @@ int main (int ac,char** av)try{
assert(!pendingRequests.empty());
auto& req=pendingRequests.front();
if(giveBool(cmwBuf)){
ring.clos(cmwBuf.giveFile(req.getFileName()));
ring.clos(cmwBuf.giveFile(req.fileName()));
toFront(frntBuf,req.frnt);
}else toFront(frntBuf,req.frnt,"CMW:",cmwBuf.giveStringView());
pendingRequests.pop_front();
Expand Down

0 comments on commit e33fcce

Please sign in to comment.