10월, 2019의 게시물 표시

Get IP address, mac address of all interface

C/C++ Way Here is a short example of how to get the ip address, mac address of all network interface in linux from a c++ program. This code is available for all Linux distributions even though I tested on the Ubuntu 18.04. #include <stdio.h> #include <stdlib.h> #include <iostream> #include <unistd.h> #include <string.h> #include <string> #include <sys/types.h> #include <ifaddrs.h> #include <linux/if_packet.h> #include <net/ethernet.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <net/if.h> #include <sys/ioctl.h> using namespace std; unsigned char * getMACAddress ( const char * pinterface) { static unsigned char mac[ 8 ]; int sock = socket(PF_INET, SOCK_DGRAM, 0 ); struct ifreq req; int i = 0 ; memset( & req, 0 , sizeof (req)); strncpy(req.ifr_name, pinterface, IF_NAMESIZE - 1 );...

SQLite Cooking

SQLite is an open source DBMS that runs embedded in a client application. It's included by default on Android, iOS, and macOS. You can easily install SQLite on Windows, Linux distros.  As the name suggests, SQLite, unlike RDBMS(MySQL, MS SQL, Oracle ...), has no network support. Provides database functionality through file I / O in applications that include SQLite support. Install SQLite If you want to use sqlite in your c/c++ application, first make sure that SQLite is installed in your operating system. [ root@localhost ~ ] # sqlite3 SQLite version 3.6.20 Enter ".help" for instructions Enter SQL statements terminated with a ";" sqlite> If your OS already has SQLite, sqlite3 command will work fine and sqlite> prompt will appear. If not installed, installl the SQLite, SQLite development packages. yum install sqlite sqlite-devel Using SQLite in c/c++ If you want to use SQLite in your c/c++ code, just include sqlite3.h header file. ...