Skip to content

Commit

Permalink
Change to library
Browse files Browse the repository at this point in the history
  • Loading branch information
Ebenezer-group committed Aug 4, 2024
1 parent 28b70f8 commit a9335fc
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion example/sendExample.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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: "<<e.what()<<"\n";}
7 changes: 4 additions & 3 deletions src/cmwBuffer.hh
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,9 @@ inline void closeSocket (sockType s){
}

inline int sockWrite (sockType s,void const* data,int len
,sockaddr const* addr=nullptr,socklen_t toLen=0){
if(int r=::sendto(s,static_cast<char const*>(data),len,0,addr,toLen);r>0)
,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());
}
Expand Down Expand Up @@ -427,7 +428,7 @@ template<class Z>class 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
Expand Down
4 changes: 2 additions & 2 deletions src/tiers/cmwA.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<udpPacketMax>(buf,{t...});
buf.send((::sockaddr*)&s.addr,s.len);
buf.send(&s.addr,s.len);
}

constexpr ::int32_t bufSize=1101000;
Expand Down Expand Up @@ -201,7 +201,7 @@ int main (int ac,char** av)try{
frntBuf.reset();
::front::marshal<udpPacketMax>(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();
Expand Down
2 changes: 1 addition & 1 deletion src/tiers/front/genz.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ int main (int ac,char** av)try{

::middle::marshal<udpPacketMax>(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);
Expand Down

0 comments on commit a9335fc

Please sign in to comment.