Skip to content

Instantly share code, notes, and snippets.

View talreg's full-sized avatar

Tal talreg

  • talreg
  • Montreal
View GitHub Profile
@talreg
talreg / socket_info.cpp
Last active September 29, 2020 12:08
getting socket info
#include <arpa/inet.h>
#include <string>
using std::string;
string getSocketIP(int socketDescriptor)
{
string ipAddress;
unsigned short remotePort; // port as well if you need it
sockaddr address;
socklen_t theSize = sizeof(address);
const int BUFFER_LEN = 60;
if(
param1>param2 and
param2>param3 and
param4>0
):
return "ok"
return "not ok"
#include<iostream>
using namespace std;
struct Test2
{
int value;
int get_value()const {
return value;
}
void inc_val(){