Skip to content

Instantly share code, notes, and snippets.

View dberzano's full-sized avatar
🥟
I love pierogi

Dario Berzano dberzano

🥟
I love pierogi
View GitHub Profile
@dberzano
dberzano / getoutipv4.cpp
Last active January 3, 2016 20:39
Returns the IPv4 address used for outbound connections by means of a "dummy" UDP socket. Tested on Linux and OS X (it should be POSIX compliant).
#include <iostream>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <cstring>
int getoutipv4(std::string *outip) {
if (!outip)