BVB Source Codes

uWebSockets Show Socket.cpp Source code

Return Download uWebSockets: download Socket.cpp Source code - Download uWebSockets Source code - Type:.cpp
  1. #include "Socket.h"
  2.  
  3. namespace uS {
  4.  
  5. Socket::Address Socket::getAddress()
  6. {
  7.     uv_os_sock_t fd = getFd();
  8.  
  9.     sockaddr_storage addr;
  10.     socklen_t addrLength = sizeof(addr);
  11.     if (getpeername(fd, (sockaddr *) &addr, &addrLength) == -1) {
  12.         return {0, "", ""};
  13.     }
  14.  
  15.     static __thread char buf[INET6_ADDRSTRLEN];
  16.  
  17.     if (addr.ss_family == AF_INET) {
  18.         sockaddr_in *ipv4 = (sockaddr_in *) &addr;
  19.         inet_ntop(AF_INET, &ipv4->sin_addr, buf, sizeof(buf));
  20.         return {ntohs(ipv4->sin_port), buf, "IPv4"};
  21.     } else {
  22.         sockaddr_in6 *ipv6 = (sockaddr_in6 *) &addr;
  23.         inet_ntop(AF_INET6, &ipv6->sin6_addr, buf, sizeof(buf));
  24.         return {ntohs(ipv6->sin6_port), buf, "IPv6"};
  25.     }
  26. }
  27.  
  28. }
  29.  
downloadSocket.cpp Source code - Download uWebSockets Source code
Related Source Codes/Software:
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
postal - 2017-06-11
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11

 Back to top