ip.hh
Go to the documentation of this file.
1 
37 #pragma once
38 
39 #include <errno.h>
40 #include <fcntl.h>
41 #include <memory>
42 #include <optional>
43 #include <tuple>
44 
45 #ifdef WIN32
46 #include <ws2tcpip.h>
47 #ifndef WIN32_LEAN_AND_MEAN
48 #define WIN32_LEAN_AND_MEAN 1
49 #endif
50 #include <windows.h>
51 #include <winsock2.h>
52 #else
53 #include <netdb.h>
54 #include <netinet/ip.h>
55 #include <unistd.h>
56 #ifndef INVALID_SOCKET
57 #define INVALID_SOCKET (-1)
58 #endif
59 #endif
60 
61 namespace multisense{
62 namespace legacy{
63 
64 #ifdef WIN32
65  typedef SOCKET socket_t;
66 #else
67  typedef int32_t socket_t;
68 #endif
69 
73 std::unique_ptr<sockaddr_in> get_sockaddr(const std::string &ip_address, uint16_t command_port);
74 
78 std::unique_ptr<sockaddr_in> get_broadcast_sockaddr(uint16_t command_port);
79 
83 std::tuple<socket_t, uint16_t> bind(const std::optional<std::string>& interface_name, bool broadcast);
84 
85 }
86 }
multisense::legacy::get_broadcast_sockaddr
std::unique_ptr< sockaddr_in > get_broadcast_sockaddr(uint16_t command_port)
Create a socketaddr_in object to boradcast to a given port.
Definition: ip.cc:70
multisense::legacy::bind
std::tuple< socket_t, uint16_t > bind(const std::optional< std::string > &interface_name, bool broadcast)
Create a UDP socket to communicate with the MultiSense. Optionally bind to a specific interface.
Definition: ip.cc:80
multisense
Definition: factory.cc:39
multisense::legacy::get_sockaddr
std::unique_ptr< sockaddr_in > get_sockaddr(const std::string &ip_address, uint16_t command_port)
Create a socketaddr_in object for a given IP address and port.
Definition: ip.cc:44
multisense::legacy::socket_t
int32_t socket_t
Definition: ip.hh:67


multisense_lib
Author(s):
autogenerated on Thu Apr 17 2025 02:49:09