diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 1999-07-02 21:02:20 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 1999-07-02 21:02:20 +0000 |
commit | 29b78b4c0417dac933bae937d42b52463545d9da (patch) | |
tree | 079722fa7d30976badb35c975d96f51cc152586f | |
parent | 39f3d3350a4d1baba3e481151013929358f1942b (diff) | |
download | ATCD-29b78b4c0417dac933bae937d42b52463545d9da.tar.gz |
.
-rw-r--r-- | ace/OS.h | 15 | ||||
-rw-r--r-- | ace/SOCK_Dgram.cpp | 92 | ||||
-rw-r--r-- | ace/SOCK_Dgram.h | 33 | ||||
-rw-r--r-- | ace/SOCK_Dgram.i | 56 |
4 files changed, 176 insertions, 20 deletions
@@ -1033,9 +1033,8 @@ typedef struct timespec class ACE_Export ACE_PSOS_Time_t { public: - - ACE_PSOS_Time_t (); - // default ctor: date, time, and ticks all zeroed + ACE_PSOS_Time_t (void); + // default ctor: date, time, and ticks all zeroed. ACE_PSOS_Time_t (const timespec_t& t); // ctor from a timespec_t @@ -1050,17 +1049,13 @@ public: // static member function to set current system time # if defined (ACE_PSOSIM) - - static u_long init_simulator_time (); + static u_long init_simulator_time (void); // static member function to initialize system time, using UNIX calls - # endif /* ACE_PSOSIM */ static const u_long max_ticks; // max number of ticks supported in a single system call - private: - // constants for prying info out of the pSOS time encoding static const u_long year_mask; static const u_long month_mask; @@ -3160,7 +3155,7 @@ struct iovec // WSABUF is a Winsock2-only type. #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) operator WSABUF &(void) { return *((WSABUF *) this); } -#endif +#endif /* defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) */ }; struct msghdr @@ -4797,10 +4792,12 @@ typedef u_long ACE_SERVICE_TYPE; #endif /* ACE_HAS_WINSOCK2_GQOS */ typedef GROUP ACE_SOCK_GROUP; typedef WSAPROTOCOL_INFO ACE_Protocol_Info; +#define ACE_OVERLAPPED_SOCKET_FLAG WSA_FLAG_OVERLAPPED #else typedef u_long ACE_SERVICE_TYPE; typedef u_long ACE_SOCK_GROUP; typedef u_long ACE_Protocol_Info; +#define ACE_OVERLAPPED_SOCKET_FLAG 0 #endif /* ACE_HAS_WINSOCK2 && ACE_HAS_WINSOCK2 != 0 */ class ACE_Export ACE_Flow_Spec diff --git a/ace/SOCK_Dgram.cpp b/ace/SOCK_Dgram.cpp index b470ffa9a3c..a4705e4d1f5 100644 --- a/ace/SOCK_Dgram.cpp +++ b/ace/SOCK_Dgram.cpp @@ -26,7 +26,7 @@ ACE_SOCK_Dgram::dump (void) const // returns the number of bytes read. ssize_t -ACE_SOCK_Dgram::recv (iovec *io_vec, +ACE_SOCK_Dgram::recv (iovec io_vec[], ACE_Addr &addr, int flags, const ACE_Time_Value *timeout) const @@ -391,3 +391,93 @@ ACE_SOCK_Dgram::recv (void *buf, return this->recv (buf, n, addr, flags); } } + +// <sendto> an N byte datagram to <addr> (connectionless version). + +ASYS_INLINE ssize_t +ACE_SOCK_Dgram::send (const void *buf, + size_t n, + const ACE_Addr &addr, + int flags) const +{ + ACE_TRACE ("ACE_SOCK_Dgram::send"); + sockaddr *saddr = (sockaddr *) addr.get_addr (); + size_t len = addr.get_size (); + return ACE_OS::sendto (this->get_handle (), + (const char *) buf, + n, + flags, + (struct sockaddr *) saddr, + len); +} + +// <recvfrom> an n byte datagram (connectionless version). + +ASYS_INLINE ssize_t +ACE_SOCK_Dgram::recv (void *buf, + size_t n, + ACE_Addr &addr, + int flags) const +{ + ACE_TRACE ("ACE_SOCK_Dgram::recv"); + sockaddr *saddr = (sockaddr *) addr.get_addr (); + int addr_len = addr.get_size (); + + ssize_t status = ACE_OS::recvfrom (this->get_handle (), + (char *) buf, + n, + flags, + (sockaddr *) saddr, + &addr_len); + addr.set_size (addr_len); + return status; +} + +ssize_t +ACE_SOCK_Dgram::send (const iovec *buffers, + int buffer_count, + size_t &number_of_bytes_sent, + int flags, + const ACE_Addr &addr, + ACE_OVERLAPPED *overlapped, + ACE_OVERLAPPED_COMPLETION_FUNC func) const +{ + ACE_TRACE ("ACE_SOCK_Dgram::send"); + sockaddr *saddr = (sockaddr *) addr.get_addr (); + size_t len = addr.get_size (); + return ACE_OS::sendto (this->get_handle (), + buffers, + buffer_count, + number_of_bytes_sent, + flags, + (const sockaddr *) saddr, + len, + overlapped, + func); +} + +ssize_t +ACE_SOCK_Dgram::recv (iovec *buffers, + int buffer_count, + size_t &number_of_bytes_recvd, + int &flags, + ACE_Addr &addr, + ACE_OVERLAPPED *overlapped, + ACE_OVERLAPPED_COMPLETION_FUNC func) const +{ + ACE_TRACE ("ACE_SOCK_IO::recv"); + sockaddr *saddr = (sockaddr *) addr.get_addr (); + int addr_len = addr.get_size (); + + ssize_t status = ACE_OS::recvfrom (this->get_handle (), + buffers, + buffer_count, + number_of_bytes_recvd, + flags, + (sockaddr *) saddr, + &addr_len, + overlapped, + func); + addr.set_size (addr_len); + return status; +} diff --git a/ace/SOCK_Dgram.h b/ace/SOCK_Dgram.h index 02fa97986d0..f781ca7f66d 100644 --- a/ace/SOCK_Dgram.h +++ b/ace/SOCK_Dgram.h @@ -75,14 +75,14 @@ public: size_t n, const ACE_Addr &addr, int flags = 0) const; - // Send an <n> byte <buf> to the datagram socket (uses sendto(3)). + // Send an <n> byte <buf> to the datagram socket (uses <sendto(3)>). ssize_t recv (void *buf, size_t n, ACE_Addr &addr, int flags = 0) const; // Receive an <n> byte <buf> from the datagram socket (uses - // recvfrom(3)). + // <recvfrom(3)>). ssize_t recv (iovec *io_vec, ACE_Addr &addr, @@ -100,14 +100,14 @@ public: const ACE_Addr &addr, int flags = 0) const; // Send an <iovec> of size <n> to the datagram socket (uses - // sendmsg(3)). + // <sendmsg(3)>). ssize_t recv (iovec iov[], size_t n, ACE_Addr &addr, int flags = 0) const; // Recv an <iovec> of size <n> to the datagram socket (uses - // recvmsg(3)). + // <recvmsg(3)>). ssize_t recv (void *buf, size_t n, @@ -122,7 +122,7 @@ public: // returned with <errno == ETIME>. If it succeeds the number of // bytes received is returned. - ssize_t send (const iovec *buffers, + ssize_t send (const iovec buffers[], int buffer_count, size_t &number_of_bytes_sent, int flags, @@ -130,9 +130,9 @@ public: ACE_OVERLAPPED *overlapped, ACE_OVERLAPPED_COMPLETION_FUNC func) const; // Send <buffer_count> worth of <buffers> to <addr> using overlapped - // I/O. + // I/O (uses <WSASentTo>). Returns 0 on success. - ssize_t recv (iovec *buffers, + ssize_t recv (iovec buffers[], int buffer_count, size_t &number_of_bytes_recvd, int &flags, @@ -140,7 +140,24 @@ public: ACE_OVERLAPPED *overlapped, ACE_OVERLAPPED_COMPLETION_FUNC func) const; // Recv <buffer_count> worth of <buffers> from <addr> using - // overlapped I/O. + // overlapped I/O (uses <WSARecvFrom>). Returns 0 on success. + + ssize_t send (const void *buf, + size_t n, + const ACE_Addr &addr, + int flags = 0, + ACE_OVERLAPPED *overlapped, + ACE_OVERLAPPED_COMPLETION_FUNC func) const; + // Send an <n> byte <buf> to the datagram socket (uses <WSASentTo>). + + ssize_t recv (void *buf, + size_t n, + ACE_Addr &addr, + int flags = 0, + ACE_OVERLAPPED *overlapped, + ACE_OVERLAPPED_COMPLETION_FUNC func) const; + // Receive an <n> byte <buf> from the datagram socket (uses + // <WSARecvFrom>). void dump (void) const; // Dump the state of an object. diff --git a/ace/SOCK_Dgram.i b/ace/SOCK_Dgram.i index b6b9a5afacf..5d713b9872e 100644 --- a/ace/SOCK_Dgram.i +++ b/ace/SOCK_Dgram.i @@ -59,7 +59,7 @@ ACE_SOCK_Dgram::recv (void *buf, } ASYS_INLINE ssize_t -ACE_SOCK_Dgram::send (const iovec *buffers, +ACE_SOCK_Dgram::send (const iovec buffers[], int buffer_count, size_t &number_of_bytes_sent, int flags, @@ -82,7 +82,7 @@ ACE_SOCK_Dgram::send (const iovec *buffers, } ASYS_INLINE ssize_t -ACE_SOCK_Dgram::recv (iovec *buffers, +ACE_SOCK_Dgram::recv (iovec buffers[], int buffer_count, size_t &number_of_bytes_recvd, int &flags, @@ -106,3 +106,55 @@ ACE_SOCK_Dgram::recv (iovec *buffers, addr.set_size (addr_len); return status; } + +// <sendto> an N byte datagram to <addr> (connectionless version). + +ASYS_INLINE ssize_t +ACE_SOCK_Dgram::send (const void *buf, + size_t n, + const ACE_Addr &addr, + int flags, + ACE_OVERLAPPED *overlapped, + ACE_OVERLAPPED_COMPLETION_FUNC func) const +{ + ACE_TRACE ("ACE_SOCK_Dgram::send"); + + iovec buffer[1]; + buffer[0].iov_len = n; + buffer[0].iov_base = buf; + size_t number_of_bytes_sent = 0; + return this->send (this->get_handle (), + buffer, + 1, + number_of_bytes_sent, + flags, + addr, + overlapped, + func); +} + +// <recvfrom> an n byte datagram (connectionless version). + +ASYS_INLINE ssize_t +ACE_SOCK_Dgram::recv (void *buf, + size_t n, + ACE_Addr &addr, + int flags, + ACE_OVERLAPPED *overlapped, + ACE_OVERLAPPED_COMPLETION_FUNC func) const +{ + ACE_TRACE ("ACE_SOCK_Dgram::recv"); + + iovec buffer[1]; + buffer[0].iov_len = n; + buffer[0].iov_base = buf; + size_t number_of_bytes_recvd = 0; + return this->recv (this->get_handle (), + buffer, + 1, + number_of_bytes_recvd, + flags, + addr, + overlapped, + func); +} |