View Antoni Milton's profile on LinkedIn

Tuesday, August 9, 2011

How to resolve the IPv6 Address from domain name in C++ ?

In general, we are using gethostbyname or gethostbyname_r for resolving IPAddress from domain name. These system calls are not supporting IPv6 format.

For resolve IPv6Address from domain name, we need to use gethostbyname2_r function.

struct in6_addr aadrv6;
struct hostent *host;
char* pszHostName = “localhost6.localdomain6”;
char strIPAddr[50];
char buffer[2048];
int iError = 0,hrr;

iError = gethostbyname2_r( pszHostName, AF_INET6, &hostbuf,buffer, 2048,&host,&hrr );

if( iError == 0 && host != NULL )
{
    memcpy( &aadrv6 , host->h_addr_list[0], sizeof( in6_addr ) );
   if( inet_ntop ( AF_INET6, &aadrv6, strIPAddr, INET6_ADDRSTRLEN ) != NULL )
   {
        printf("IPv6Address: %s\n", strIPAddr);
    }
}

output:
#./a.out
IPv6Address: ::1

Thursday, October 14, 2010

In Linux anything is equivalent to windows registry?

I saw the questions in many Linux forums

The RPM package information stored in the below location

/var/lib/rpm
[root@hostrpm]# ls
Basenames     __db.000  __db.002  Dirnames  Group       Name      Providename     Pubkeys      Requireversion  Sigmd5
Conflictname  __db.001  __db.003  Filemd5s  Installtid  Packages  Provideversion  Requirename  Sha1header      Triggername

It uses Berkeley DB as its back-end. It consists of a single database (Packages) containing all of the meta information of the installed rpms.
The RPM database is used to keep track of all files that are changed and created when a user installs a package. If the database gets corrupted, the index databases can be recreated with the rpm --rebuilddb command.

If you issues the rpm- qa ( query ) command then, it will read from the DB and list out the package names.

If you delete the installation directory directly, it won’t delete the record from the RPM DB. For that you need to execute the rpm –ivh (uninstall ) command , otherwise you can’t install the same package.

Thursday, July 8, 2010

How to check CPU and memory Hardware detials in RHEL system?

Using the bellow command, we can see the Memory and CPU related hardware details

#cat  /proc/meminfo


#cat  /proc/cpuinfo

Wednesday, June 9, 2010

How to write / setup SCTP client server program in RHEL system?

Setup:

Before run any SCTP application, we need to install SCTP libs from

http://lksctp.sourceforge.net/

Using the below command, register the SCTP module into kernel.

#modprobe sctp

http://linux.about.com/od/commands/l/blcmdl8_modprob.htm


SCTP Application writing:-


SCTP client and server system call follow same as TCP. ( like socket,bind,listen and accept )

Creating SCTP socket

Sock = socket( AF_INET, SOCK_STREAM, IPPROTO_SCTP );

Before listen, we need to set the value for the no.of stream for the socket using setsockopt system call.

struct sctp_initmsg startupsctp;

startupsctp.sinit_num_ostreams = 3;

startupsctp.sinit_max_instreams = 3;

startupsctp.sinit_max_attempts = 4;

ret = setsockopt( listen_Socket, IPPROTO_SCTP, SCTP_INITMSG, & startupsctp, sizeof(startupsctp) );

Using sctp_sendmsg() and sctp_recvmsg() system calls , we can send/receive data over the SCTP socket.


Example code:-

Please refer : http://www.ibm.com/developerworks/linux/library/l-sctp/

Tuesday, May 25, 2010

How to decompress the tar.bz2 format file?

#tar -xvjf xxxx.tar.bz2
tmp/test.txt

Options:

* x - extract
* c - create to create
* v - verbose
* z - gzip
* j - bzip2 ( .bz2 )
* f - file name ( after the “f” indicate the input/output file name )

Monday, April 5, 2010

How to prepare ISO image and test it?

An ISO image is an archive file/disc image of an optical disc in a format defined by the International Organization for Standardization (ISO). ISO image files typically have a file extension of .iso

Create folder name with "
cd"

#mkdir
cd
#cd
cd

copy your application/package/rpm/script file into the folder
#cp /root/test/Add-lnx26.sh .
#ls
Add-lnx26.sh

run the below command for creating the iso image with the name of add.iso

#cd ..

#mkisofs -l -r -N -d -D -J -o add.iso -V "Add-1.0" -A "Add program for ISO image test" cd

Warning: creating filesystem that does not conform to ISO-9660.
Total translation table size: 0
Total rockridge attributes bytes: 247
Total directory bytes: 0
Path table size(bytes): 10
Max brk space used c000
182 extents written (0 MB)

#ls
cd add.iso