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 [...]
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 [...]
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 [...]
23
2011
Gui whois client in python with wxpython
Wxpython is the python port of wxwidgets gui library. On ubuntu wxpython can be installed from synaptic. On windows it can be downloaded from the website wxpython.org And here is a small program that pops up a simple window , to take a domain name and perform a whois for that domain.
23
2011
Whois client code in C with Linux sockets
A whois client is a program that will simply fetch the whois information for a domain/ip address from the whois servers. The code over here works according to the algorithm discussed here. Code hostname_to_ip – This is a simple function to get an IP of a domain. str_replace – This is a generic string processing function that is used to search for a string in another big string and replace it with another string. Output
20
2011
Get local ip in C on linux
The local ip is the source ip in IP packets send out from a system. The kernal maintains routing tables which it uses to decide the default gateway , its interface and the local ip configured for that interface. The /proc/net/route file (not really a file but appears like one) has more information about it. A typical /proc/net/route output would look like : The above lists the interface , destination , gateway etc. The interface [...]
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++ [...]
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 [...]
10
2011
Get ip address from hostname in C using Linux sockets
Here are 2 methods to get the ip address of a hostname : The first method uses the traditional gethostbyname function to retrieve information about a hostname/domain name. Code Compile and Run The second method uses the getaddrinfo function to retrieve information about a hostname/domain name. Code Compile and Run
1
2011
Packet Sniffer Code in C using Linux Sockets (BSD) – Part 2
In the previous part we made a simple sniffer which created a raw socket and started receiving on it. But it had few drawbacks : 1. Could sniff only incoming data. 2. Could sniff only TCP or UDP or ICMP or any one protocol packets at a time. 3. Provided IP frames , so ethernet headers were not available. In this article we are going to modify the same code to fix the above 3 [...]
Subscribe
Recent Posts
- Compile wxwebconnect on Ubuntu 11.04 64 bit
- Disqus Comments Importer Script in PHP
- Beginners’ guide to socket programming with winsock
- Handle multiple socket connections with fd_set and select on Linux
- Beginners guide to socket programming in C on Linux
- Gui whois client in python with wxpython
- Whois client code in C with Linux sockets
- str_replace for C
- Easy to use C/C++ IDE for Ubuntu Linux
- Get local ip in C on linux
An article by Binary Tides