Inexor
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
IsLocalConnection.hpp
Go to the documentation of this file.
1 
4 #pragma once
5 
6 #ifdef WIN32
7 #include <Winsock2.h>
8 #include <ws2tcpip.h>
9 #else
10 #include <sys/socket.h>
11 #endif
12 
13 inline bool IsLocalConnection(int socketfd) {
14  sockaddr_in RemAddr, LocAddr;
15  socklen_t Len = sizeof(RemAddr);
16  getpeername(socketfd, (sockaddr *)&RemAddr, &Len);
17  getsockname(socketfd, (sockaddr *)&LocAddr, &Len);
18  return (RemAddr.sin_addr.s_addr == LocAddr.sin_addr.s_addr);
19 }
bool IsLocalConnection(int socketfd)
Is the connection from the same machine?
Definition: IsLocalConnection.hpp:13