In this invention we provide application level compression. Compression and decompression capabilities are provided to client side application code and server side application code as a separate library. Both client side application code and server side application code here have the capability of invoking compression and decompression facilities provided by the library and hence they register with the respective libraries on the client side and server side with the same unique application identifier helping them differentiate from other client-server applications. Client side application code and server side application code also register with the respective libraries provided to them, the socket descriptors to uniquely identify various connection endpoints for different connections for reading and writing. So for every connection both client and server side libraries maintain a pair of application identifier and a socket descriptor for reading and writing. Along with the library, client side application code and server side application code are provided with a configurable parameter to choose a compression algorithm like Huffman coding, Lempel–Ziv–Welch (LZW) etc. In this invention for any data transfer, the client or server side application code which wants to send data to the other end invokes the library provided and if the data to be transferred is above a certain threshold then it sends a special packet to the other end including the application identifier, total compressed data bytes to be transferred which is calculated after compressing the original data bytes to be transferred and the compression algorithm to be used, with the help of socket descriptor provided to it for the connection. The library at the other end on receiving the total number of compressed data bytes decompresses the data based on the information it received in the special packet for the requisite application and the application code at the other end then processes decompressed data.