Category Archives: C

Socket Programming in C

Receive full data with recv socket function in C

By | September 8, 2012

recv The recv function is used to receive data on a socket. For example here is the code to fetch the home page of www.msn.com The output might be something like this $ gcc simple_client.c && ./a.out Connected Data Send Reply received HTTP/1.1 200 OK Cache-Control: no-cache, no-store Pragma: no-cache Content-Type: text/html; charset=utf-8 Vary: Accept-Encoding… Read More »

C code to perform IP whois

By | February 16, 2012

Theory The whois information of an ip address provides various details like its network, range, isp etc. This information is maintained by various regional registry servers. Read the wikipedia article on regional internet registries for more information. There are a total of 5 regional registries spanning various geographical regions of the world. For example if… Read More »

Handle multiple socket connections with fd_set and select on Linux

By | December 25, 2011

Handle multiple socket connections 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… Read More »