Skip to main content

Implementing Socket Programming in Java

Socket programming is the foundation of network communication in Java. A socket is one endpoint of a two-way communication channel between two programs running on a network. Java provides the java.net package with high-level abstractions — ServerSocket for the server side and Socket for the client side — that handle the underlying TCP/IP details so you can focus on reading and writing data streams. This example implements a simple interactive TCP chat between a server and a client. Both sides can send and receive messages. Either side can type Q or q to close the connection gracefully. The server listens on port 5000; the client connects to localhost:5000.

Illustrating Working of Bit-Map Protocol with C++ Program

The Bit-Map Protocol is a contention-free MAC (Medium Access Control) layer protocol used to coordinate which stations are allowed to transmit on a shared channel. Before any data frame is sent, each station broadcasts a single bit during its reserved slot in a contention slot period: a 1 signals that the station has a frame ready to send, while a 0 means the station has nothing to transmit. Once every station has announced its status, transmissions occur in station order, eliminating collisions entirely. This C++ program simulates the Bit-Map Protocol. The user specifies the number of stations and their ready/not-ready status. The program reads each station's status, then announces which stations are ready to transmit in station-number order.

Implementation of Cyclic Redundancy Check Algorithm in C++

Cyclic Redundancy Check (CRC) is one of the most widely used error-detection techniques in data communications. The sender treats the data frame as a binary number, appends zeros equal to one less than the generator polynomial length, and then divides the extended frame by the generator using XOR (modulo-2) division. The remainder — called the CRC bits — is appended to the original frame before transmission. At the receiver, the same division is performed on the received frame. If the remainder is zero, the frame arrived without errors; a non-zero remainder indicates corruption. This C++ program demonstrates both the sender-side CRC generation and the receiver-side error check for a user-supplied frame and generator.

Implementation of Dijkstra Algorithm in C++

Dijkstra's Algorithm is a classic greedy algorithm for finding the shortest path from a single source vertex to all other vertices in a weighted graph with non-negative edge weights. It maintains a set of visited vertices and a distance array. At each step it selects the unvisited vertex with the smallest known distance, marks it visited, and relaxes (updates) the distances of its neighbours. This process repeats until all vertices have been visited. This C++ program reads a cost matrix from the user (entering -1 for absent edges and 0 for self-loops), runs Dijkstra's algorithm from a user-specified source vertex, and prints the shortest distance and parent vertex for every node.

Implementation of Distance Vector Routing (DVR) Algorithm in C++

This is an outdated post! Please click here to see latest version of Implementation of Distance Vector Routing (DVR) Algorithm in C++ The Distance Vector Routing (DVR) Algorithm is a fundamental routing algorithm used in computer networks to determine the shortest path between nodes. It is based on the Bellman-Ford algorithm and operates by sharing routing tables among directly connected nodes to update their knowledge about the shortest paths. In this blog post, we will discuss the implementation of the DVR algorithm in C++, go through the code step by step, and explain its output.

C++ Program to Copy Text from One File to Another

File I/O is a fundamental skill in systems programming. This C++ program demonstrates how to copy the contents of one text file to another using standard C file functions: fopen(), fgetc(), fputc(), feof(), and fclose(). The program opens the source file in read mode and the destination file in write mode, then reads characters one at a time from the source and writes each character to the destination until the end of the source file is reached. This approach is a classic example of character-level file copying — simple, portable, and easy to trace. It also shows basic error handling: if the source file cannot be opened (e.g., path does not exist), the program reports an error instead of proceeding.

Mix (Assembly and C++) Program to Find Greatest of Two Numbers

This program demonstrates how to compare two integers using 8086 inline assembly in C++. By leveraging assembly instructions like sub and conditional jump js, the program determines which number is greater. #include<iostream.h> #include<conio.h> void main() { clrscr(); short a; short b; cout << "\n Enter First Number:"; cin >> a; cout << "\n Enter Second Number:"; cin >> b; asm mov ax, 0000h // Clear AX asm mov bx, 0000h // Clear BX asm mov ax, a // Load first number into AX asm mov bx, b // Load second number into BX asm sub ax, bx // Subtract BX from AX asm js true // Jump if result is negative (AX < BX) cout << "\n " << a << " is greater than " << b; asm jmp end // Skip 'true' block true: cout << "\n " << b << " is greater than " << a; end: getch(); }

Implementation of Hamming Code in C++

The Hamming Code is an error-detection and error-correction technique developed by Richard Hamming. It introduces redundancy bits (also called parity bits) into a data frame at specific positions that are powers of 2 (positions 1, 2, 4, 8, …). Each redundancy bit covers a set of data bits determined by the binary representation of their positions. At the receiver's end, the syndrome bits are recalculated and XOR-compared with the received parity bits — a non-zero result identifies the exact bit position where an error occurred. This C++ program takes a data frame and the number of redundancy bits as input, inserts parity bits at the appropriate positions, simulates a single-bit error at a user-specified location, recalculates the syndrome, and reports the error position.

8086 Assembly Program to Print ‘hello’ using 09H

DOS interrupt 21h function 09h is the easiest way to print a string in 8086 assembly: point DX at your string, set AH to 09h, call INT 21h, and you’re done. No loop, no character counter, no BX pointer arithmetic. The tradeoff is a minor convention: the string must end with a $ character so DOS knows where to stop. Compare this with the function 02h character loop approach — 09h is cleaner for fixed strings; 02h gives you more control for dynamic output.

Interrupting BIOS with 8086 Assembly Program

INT 10h is the BIOS video interrupt — completely separate from the DOS INT 21h family. Where INT 21h talks to the operating system, INT 10h talks directly to the video BIOS to control the screen: cursor shape, cursor position, character output, screen modes. This short program demonstrates two of those functions: setting the cursor shape and moving it to a specific screen position.