Browsing articles in "Programming"
Feb
16
2012

C code to perform IP whois

Theory First whois.iana.org is queried to find out the regional internet registry of the specified IP address. Then the whois server of the corresponding RIR is queried to get the actual whois information about the ip. Implementation is simple Code Linux : Compile and Run

Feb
7
2012

Quick Tip: Getting the Next and Previous Items or Posts

It is a common requirement in lots of projects to fetch the next and previous items or posts and display a link to them on every item or post page. Getting the previous and next item can be quite tricky especially if they need to be user-specific, although it is very easy. I’ll show you how – Instead of 2 round-trips, you can even query the DB once. The trick is to use UNION :)

Jan
25
2012

Disqus Comments Importer Script in PHP

Disqus is a great commenting platform that does it’s job really well. Many people use it these days because writing your own commenting system is a tedious and hard work whereas a solution like Disqus or Livefyre makes the entire commenting process a breeze with features like social logins, many levels of nesting, easy replying, quick and realtime commenting, easy integration, intuitive admin panel to manage your comments, email notifications, managing comments via emails directly, [...]

Dec
26
2011

Beginners’ guide to socket programming with winsock

What is this about This is a quick guide/tutorial to learning socket programming in C language on Windows. “Windows” because the code snippets shown over here will work only on Windows. The windows api to socket programming is called winsock. Sockets are the fundamental “things” behind any kind of network communications done by your computer. For example when you type www.google.com in your web browser, it opens a socket and connects to google.com to fetch [...]

Dec
25
2011

Handle multiple socket connections with fd_set and select on Linux

When writing server programs using sockets , it becomes necessary to handle multiple connections at a time , since a server needs to serve multiple clients. There are many ways to do so. On linux this can be done in various ways like forking , threading , select method etc. In this tutorial we shall use the select method approach. The select function allows the program to monitor multiple sockets for a certain “activity” to [...]

Dec
24
2011

Beginners guide to socket programming in C on Linux

What is this about This is a quick guide/tutorial to learning socket programming in C language on a Linux system. “Linux” because the code snippets shown over here will work only on a Linux system and not on Windows. The windows api to socket programming is called winsock and we shall go through it in another tutorial. Sockets are the fundamental “things” behind any kind of network communications done by your computer. For example when [...]

Dec
22
2011

str_replace for C

Php has a useful function called str_replace which can search and replace a certain string in another big string. However there is no such function in C. So I wrote up one for myself. Here is the code. Usage Output

Dec
18
2011

Code a packet sniffer in C with winpcap

Winpcap is a packet capture library for Windows used for packet sniffing and sending raw packets. Wireshark is a popular sniffer tool that uses winpcap to sniff packets. Here is a sample code which shows how winpcap can be used to sniff incoming packets on a particular interface. Code Compile The code can be compiled in Vc++ 2010 Express Edition Winpcap development files are needed for pcap.h/pcap.lib and other files. Create a project in VC++ [...]

Dec
16
2011

Get mac address from ip in winsock

Mac address or hardware address is a 48bit (6 character) wide address assigned to a network interface. It is important for the packet delivery between 2 devices like your computer and the router. Ethernet protocol uses the mac address to deliver it to the right network node. It looks like this 00-1E-58-B8-D4-69 ( the dash is not relevant). Mac address of any interface can also be changed ( called mac spoofing ) . Any network [...]

Pages:12345678»