From a9335fcc6377cbbff7ff39b214920838b140c69f Mon Sep 17 00:00:00 2001 From: Ebenezer-group Date: Sun, 4 Aug 2024 15:48:16 -0500 Subject: [PATCH] Change to library --- example/sendExample.cc | 2 +- src/cmwBuffer.hh | 7 ++++--- src/tiers/cmwA.cc | 4 ++-- src/tiers/front/genz.cc | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/example/sendExample.cc b/example/sendExample.cc index 3878e03..d7b125c 100644 --- a/example/sendExample.cc +++ b/example/sendExample.cc @@ -44,5 +44,5 @@ int main ()try{ std::cout<<"unknown message id\n"; return 0; } - buf.send((sockaddr*)&sa,sizeof(sa)); + buf.send(&sa,sizeof(sa)); }catch(::std::exception& e){::std::cout<<"failure: "<(data),len,0,addr,toLen);r>0) + ,auto addr=nullptr,socklen_t toLen=0){ + if(int r=::sendto(s,static_cast(data),len,0, + reinterpret_cast<::sockaddr const*>(addr),toLen);r>0) return r; raise("sockWrite",s,getError()); } @@ -427,7 +428,7 @@ templateclass SendBuffer{ } //UDP-friendly alternative to flush - void send (::sockaddr* addr=nullptr,::socklen_t len=0) + void send (auto addr=nullptr,::socklen_t len=0) {sockWrite(sock_,buf,index,addr,len);} #ifndef CMW_WINDOWS diff --git a/src/tiers/cmwA.cc b/src/tiers/cmwA.cc index 302740d..4bbad3a 100644 --- a/src/tiers/cmwA.cc +++ b/src/tiers/cmwA.cc @@ -97,7 +97,7 @@ void checkField (char const* fld,::std::string_view actl){ void toFront (auto& buf,Socky const& s,auto...t){ buf.reset(); ::front::marshal(buf,{t...}); - buf.send((::sockaddr*)&s.addr,s.len); + buf.send(&s.addr,s.len); } constexpr ::int32_t bufSize=1101000; @@ -201,7 +201,7 @@ int main (int ac,char** av)try{ frntBuf.reset(); ::front::marshal(frntBuf,{"Back tier vanished"}); for(auto& r:pendingRequests){ - frntBuf.send((::sockaddr*)&r.frnt.addr,r.frnt.len); + frntBuf.send(&r.frnt.addr,r.frnt.len); } pendingRequests.clear(); cmwBuf.compressedReset(); diff --git a/src/tiers/front/genz.cc b/src/tiers/front/genz.cc index beda459..eeb4031 100644 --- a/src/tiers/front/genz.cc +++ b/src/tiers/front/genz.cc @@ -18,7 +18,7 @@ int main (int ac,char** av)try{ ::middle::marshal(buf,MarshallingInt(av[1]),av[2]); for(int tm=8;tm<13;tm+=4){ - buf.send((::sockaddr*)&sa,sizeof sa); + buf.send(&sa,sizeof sa); setRcvTimeout(buf.sock_,tm); if(buf.getPacket()){ if(giveBool(buf))::std::exit(EXIT_SUCCESS);