Browse Source

faux.net: Add faux_net_get_fd()

Serj Kalichev 3 years ago
parent
commit
a98fe530a1
2 changed files with 14 additions and 0 deletions
  1. 1 0
      faux/net.h
  2. 13 0
      faux/net/net.c

+ 1 - 0
faux/net.h

@@ -38,6 +38,7 @@ ssize_t faux_recvv_block(int fd, struct iovec *iov, int iovcnt,
 faux_net_t *faux_net_new(void);
 void faux_net_free(faux_net_t *faux_net);
 void faux_net_set_fd(faux_net_t *faux_net, int fd);
+int faux_net_get_fd(faux_net_t *faux_net);
 void faux_net_set_send_timeout(faux_net_t *faux_net, struct timespec *send_timeout);
 void faux_net_set_recv_timeout(faux_net_t *faux_net, struct timespec *recv_timeout);
 void faux_net_set_timeout(faux_net_t *faux_net, struct timespec *timeout);

+ 13 - 0
faux/net/net.c

@@ -80,6 +80,19 @@ void faux_net_set_fd(faux_net_t *faux_net, int fd)
 }
 
 
+/** @brief Gets file descriptor from object.
+ *
+ * @param [in] faux_net The faux_net_t object.
+ * @return File descriptor from object.
+ */
+int faux_net_get_fd(faux_net_t *faux_net)
+{
+	if (!faux_net)
+		return -1;
+	return faux_net->fd;
+}
+
+
 /** @brief Sets timeout for send operation.
  *
  * @param [in] faux_net The faux_net_t object.