50 #include <sys/types.h> 57 #include <arpa/inet.h> 61 #include <netinet/in.h> 62 #include <netinet/tcp.h> 70 #define getpid _getpid 71 #define ROS_INVALID_SOCKET INVALID_SOCKET 72 #define ROS_SOCKETS_SHUT_RDWR SD_BOTH 73 #define ROS_SOCKETS_ASYNCHRONOUS_CONNECT_RETURN WSAEWOULDBLOCK 75 #define POLLRDNORM 0x0100 78 #define POLLRDBAND 0x0200 81 #define POLLIN (POLLRDNORM | POLLRDBAND) 84 #define POLLPRI 0x0400 88 #define POLLWRNORM 0x0010 91 #define POLLOUT (POLLWRNORM) 94 #define POLLWRBAND 0x0020 97 #define POLLERR 0x0001 100 #define POLLHUP 0x0002 103 #define POLLNVAL 0x0004 106 #define ROS_SOCKETS_SHUT_RDWR SHUT_RDWR 107 #define ROS_INVALID_SOCKET ((int) -1) 108 #define ROS_SOCKETS_ASYNCHRONOUS_CONNECT_RETURN EINPROGRESS 131 typedef unsigned long int nfds_t;
171 #ifdef WIN32 // use a socket pair 172 ::closesocket(signal_pair[0]);
173 ::closesocket(signal_pair[1]);
174 #else // use a socket pair on mingw or pipe pair on linux, either way, close works 175 ::close(signal_pair[0]);
176 ::close(signal_pair[1]);
186 inline int write_signal(
const signal_fd_t &signal,
const char *buffer,
const unsigned int &nbyte) {
187 return ::send(signal, buffer, nbyte, 0);
191 inline ssize_t
write_signal(
const signal_fd_t &signal,
const void *buffer,
const size_t &nbyte) {
192 return write(signal, buffer, nbyte);
203 inline int read_signal(
const signal_fd_t &signal,
char *buffer,
const unsigned int &nbyte) {
204 return ::recv(signal, buffer, nbyte, 0);
208 inline ssize_t
read_signal(
const signal_fd_t &signal,
void *buffer,
const size_t &nbyte) {
209 return read(signal, buffer, nbyte);
ROSCPP_DECL void del_socket_from_watcher(int epfd, int fd)
ROSCPP_DECL int create_socket_watcher()
ROSCPP_DECL int set_non_blocking(socket_fd_t &socket)
ROSCPP_DECL void close_socket_watcher(int fd)
ROSCPP_DECL const char * last_socket_error_string()
ssize_t write_signal(const signal_fd_t &signal, const void *buffer, const size_t &nbyte)
ROSCPP_DECL bool last_socket_error_is_would_block()
ROSCPP_DECL pollfd_vector_ptr poll_sockets(int epfd, socket_pollfd *fds, nfds_t nfds, int timeout)
A cross platform polling function for sockets.
ssize_t read_signal(const signal_fd_t &signal, void *buffer, const size_t &nbyte)
struct pollfd socket_pollfd
ROSCPP_DECL void set_events_on_socket(int epfd, int fd, int events)
void close_signal_pair(signal_fd_t signal_pair[2])
ROSCPP_DECL int create_signal_pair(signal_fd_t signal_pair[2])
boost::shared_ptr< std::vector< socket_pollfd > > pollfd_vector_ptr
ROSCPP_DECL int last_socket_error()
ROSCPP_DECL int close_socket(socket_fd_t &socket)
Close the socket.
ROSCPP_DECL void add_socket_to_watcher(int epfd, int fd)