Neo
This user hasn't shared any biographical information
Posts by Neo
How to enable X server on network in Fedora Linux systems
Sep 27th
Please read How to view remote UNIX desktop from Microsoft Windows system to know more about accessing X server from a remote host.
X server comes with built-in support for remote desktop because of its client and server architecture. In Fedora Linux systems, X server is disabled on the network by default. That means the X client programs residing on the same host only can connect to X server. If enabled, typically X server runs on port 6000.
To enable X server on the network, search for DisallowTCP in /etc/X11/gdm/gdm.conf file and modify it to look like the following.
DisallowTCP=false
You may have to either restart the More >
How to view remote UNIX desktop from Microsoft Windows system
Sep 27th
X server is the default Graphical User Interface (GUI) toolkit used in almost all flavors of UNIX family of operating systems and most notably Linux and FreeBSD. The famous desktops are KDE and GNOME. X server toolkit has bulit-in support for remote desktops because of its client and server architecture. X server hides the underlying graphics hardware and presents a unified Application Interface (API) for client programs like KDE and GNOME applications. Unlike Microsoft Windows, the client program can reside in another host and X server can reside on another host. i.e A Windows user with a X server software like More >
Map a directory with long pathname to a virtual drive in Microsoft Windows
Sep 27th
It is often very inconvenient to type long path names to move to a directory. Also sometimes code compilation fails if your command is taking more than certain length. In such cases, the base directory can be mapped to a Windows virtual drive so that the length of path can be reduced. For example “c:\mywork\myproject\release-10\” can be mapped to an unused drive “z:\“. Since then all files and directories present in “c:\mywork\myproject\release-10\” can be accessed using “z:\” as prefix.
Some old GNU compilation tools complain that command is too long when you have long pathnames and lot of command-line options. In More >
Script to delete CVS or SVN directories recursively for source code packaging
Sep 22nd
It is required to remove directories created by source code version control systems like CVS and SVN before releasing the source code. This can be done using the following command at the bash shell.
- Move to top level directory of your project sources
- Run the following commands
bash# find . -iname CVS -type d | xargs rm -rf bash# find . -iname .svn -type d | xargs rm -rf
Quick guide to profile C/C++ source code with gprof
Sep 22nd
This article is just a quick reference for profiing C/C++ source code using gprof. C/C++ source code can be profiled using gprof in three steps.
- Compile the sources and link the program with profiling options “-pg”
bash# gcc -pg -g -c source1.c source2.c bash# gcc -pg -o myapp source1.o source2.o
- Execute the program to generate profiling output in gmon.out
bash# ./myapp
- Analyze the profiling output with gprof. It prints the list of functions which have taken more time during the execution of process. This list is in descending order so probably you would want to start optimizing the code in the same order.The output also More >
PHP Page Redirection
Jul 27th
This article explains how to redirect to another page using PHP. You can use header function in the beginning of PHP script to inform browser about page redirection. Basically this writes Hyper Text Transfer Protocol(HTTP) header with the field Location. You should not write any text before writing HTTP header. However you can have some text after writing header and it will appear in the browser while browser attempts to access the new page. Generally you won’t notice the message unless your internet connection is slow and browser is taking more time to retrieve new file.
<?php
header('Location: http://mysite.com/newpage.html');
?>
More >
How to resolve “Address already in use” error with bind system call
Jul 26th
To get rid of “Address already in use” error with bind system call, SO_REUSEADDR socket option should be set before invoking bind. This makes operating system to allow the socket to bind if there is no active socket bound to the requested address and port. Add the following code to the code snippet provided in “Find peer IP address and port number using getpeername” article.
/* create a socket */
sd = socket(AF_INET,SOCK_STREAM,0);
opt = 1;
if(setsockopt (sd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof (opt)) < 0) {
perror("setsockopt");
exit(1);
}
...
Find local IP address and local port number using getsockname
Jul 26th
The getsockname function can be used to find the local port used by a given socket. It is valid to use this function only if the socket is already using a local port number. i.e A server socket which invoked bind system call with zero as port number. A client socket which has established connection to a server. In either case operating system selects an unused port number automatically. Similarly this function can also be used on UDP sockets.
The following code snippet explains how to use getsockname to retrieve the local port number assigned by operating system.
#include <stdio.h> #include <stdlib.h> #include <string.h> #include More >
Find peer IP address and port number using getpeername
Jul 26th
The getpeername function can be used to retrieve the peer IP address and port number on a given socket. For this to work, the socket should have a valid TCP connection established. Typically this is used by server to find the IP address and port number of client.
In the following code snippet, a TCP server binds to port number 5555 and waits for clients. It retrieves client’s IP address and port number using getpeername if a client is connected.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <netinet/in.h>
#include <netdb.h>
#include <sys/types.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <sys/un.h>
int main()
{
struct sockaddr_in sin; More > How to extract files from RPM
Jul 26th
All the files present in a RPM file can be extracted using rpm2cpio and cpio utilities. The rpm2cpio command is used to convert RPM to cpio compatible archive and cpio command can be used to extract files from the archive.
The following example shows how extract files from ElectricFence RPM.
[liz@techpulp ~]# rpm2cpio ElectricFence-2.2.2-23.rpm | cpio -idv


Recent Comments