proxygen
ConnectedWriteUDPClient Class Reference
Inheritance diagram for ConnectedWriteUDPClient:
UDPClient folly::AsyncTimeout folly::AsyncTimeout

Public Member Functions

 ~ConnectedWriteUDPClient () override=default
 
 ConnectedWriteUDPClient (EventBase *evb)
 
void writePing (std::unique_ptr< folly::IOBuf > buf) override
 
- Public Member Functions inherited from UDPClient
 UDPClient (EventBase *evb, TestData &testData)
 
void start (const folly::SocketAddress &server)
 
void connect ()
 
void shutdown ()
 
void sendPing ()
 
virtual void writePing (std::unique_ptr< folly::IOBuf > buf, int gso)
 
void getReadBuffer (void **buf, size_t *len) noexceptoverride
 
void onDataAvailable (const folly::SocketAddress &, size_t len, bool) noexceptoverride
 
void onReadError (const folly::AsyncSocketException &ex) noexceptoverride
 
void onReadClosed () noexceptoverride
 
void timeoutExpired () noexceptoverride
 
AsyncUDPSocketgetSocket ()
 
void setShouldConnect (const folly::SocketAddress &connectAddr)
 
 UDPClient (EventBase *evb)
 
void start (const folly::SocketAddress &server, int n)
 
void connect ()
 
void shutdown ()
 
void sendPing ()
 
void getReadBuffer (void **buf, size_t *len) noexceptoverride
 
void onDataAvailable (const folly::SocketAddress &client, size_t len, bool truncated) noexceptoverride
 
void onReadError (const folly::AsyncSocketException &ex) noexceptoverride
 
void onReadClosed () noexceptoverride
 
void timeoutExpired () noexceptoverride
 
int pongRecvd () const
 
AsyncUDPSocketgetSocket ()
 
void setShouldConnect (const folly::SocketAddress &connectAddr)
 

Additional Inherited Members

- Protected Attributes inherited from UDPClient
folly::Optional< folly::SocketAddressconnectAddr_
 
EventBase *const evb_ {nullptr}
 
folly::SocketAddress server_
 
std::unique_ptr< AsyncUDPSocketsocket_
 

Detailed Description

Definition at line 287 of file AsyncUDPSocketTest.cpp.

Constructor & Destructor Documentation

ConnectedWriteUDPClient::~ConnectedWriteUDPClient ( )
overridedefault
ConnectedWriteUDPClient::ConnectedWriteUDPClient ( EventBase evb)
inline

Definition at line 291 of file AsyncUDPSocketTest.cpp.

291 : UDPClient(evb) {}
UDPClient(EventBase *evb, TestData &testData)

Member Function Documentation

void ConnectedWriteUDPClient::writePing ( std::unique_ptr< folly::IOBuf buf)
inlineoverridevirtual

Reimplemented from UDPClient.

Definition at line 295 of file AsyncUDPSocketTest.cpp.

References folly::IOBuf::coalesce(), folly::netops::connect(), folly::IOBuf::data(), folly::IOBuf::fillIov(), folly::IOBuf::length(), folly::AsyncSocketException::NOT_OPEN, folly::netops::sendmsg(), socket_, uint8_t, and UNLIKELY.

295  {
296  iovec vec[16];
297  size_t iovec_len = buf->fillIov(vec, sizeof(vec) / sizeof(vec[0]));
298  if (UNLIKELY(iovec_len == 0)) {
299  buf->coalesce();
300  vec[0].iov_base = const_cast<uint8_t*>(buf->data());
301  vec[0].iov_len = buf->length();
302  iovec_len = 1;
303  }
304 
305  struct msghdr msg;
306  msg.msg_name = nullptr;
307  msg.msg_namelen = 0;
308  msg.msg_iov = const_cast<struct iovec*>(vec);
309  msg.msg_iovlen = iovec_len;
310  msg.msg_control = nullptr;
311  msg.msg_controllen = 0;
312  msg.msg_flags = 0;
313 
314  ssize_t ret = ::sendmsg(socket_->getFD(), &msg, 0);
315  if (ret == -1) {
316  if (errno != EAGAIN || errno != EWOULDBLOCK) {
318  folly::AsyncSocketException::NOT_OPEN, "WriteFail", errno);
319  }
320  }
321  connect();
322  }
ssize_t sendmsg(NetworkSocket socket, const msghdr *message, int flags)
Definition: NetOps.cpp:328
std::unique_ptr< AsyncUDPSocket > socket_
ByteRange coalesce()
Definition: IOBuf.h:1095
const uint8_t * data() const
Definition: IOBuf.h:499
size_t fillIov(struct iovec *iov, size_t len) const
Definition: IOBuf.cpp:1072
std::size_t length() const
Definition: IOBuf.h:533
Definition: Traits.h:588
vector< string > vec
Definition: StringTest.cpp:35
#define UNLIKELY(x)
Definition: Likely.h:48

The documentation for this class was generated from the following file: