A full-stack desktop communication platform built in C# .NET Windows Forms — enabling real-time text chat, video/audio calling, and file transfer over a Local Area Network without any internet dependency. Implemented with raw UDP sockets for peer-to-peer messaging, a custom Wave audio engine for voice transmission, a 3-tier architecture (GUI → Business Object Layer → SQL Server), and persistent chat history backed by SQL Server Express.
This project is a Skype-like desktop communication suite that operates entirely over a Local Area Network — no internet, no third-party server, no cloud dependency. Any two machines on the same LAN can communicate directly by exchanging IP addresses and port numbers, making it ideal for closed networks such as university labs, offices, or corporate intranets.
The application was developed to explore low-level socket programming in C# — specifically how to build real-time bidirectional communication using raw UDP datagrams, handle asynchronous callbacks for non-blocking message receipt, and manage application state across multiple Windows Forms screens.
The software covers all three core communication modes: text chat via UDP with persistent history stored in SQL Server, voice/audio calls using a fully custom Wave audio engine that wraps Windows multimedia APIs via P/Invoke (no external libraries), and file transfer over the same LAN infrastructure. User accounts (login, signup) are managed with a dedicated Business Object layer separating data access from the UI.
The architecture follows a clean 3-tier pattern: the GUI layer (Windows Forms) talks exclusively to the BOLayer (a dedicated C# class library) which in turn manages all SQL Server interactions — a design pattern that was also applied in enterprise EDI systems later in the career at Spring Systems.
The application is structured as a 3-tier Windows application with a separate Visual Studio solution project for each layer. The GUI layer handles all Windows Forms events; the Business Object Layer (compiled as a separate DLL) isolates all SQL Server operations; and the database tier uses a local SQL Server Express .mdf file that can optionally be shared across a LAN via a database server for multi-user persistence.
Three communication modes are integrated into a single desktop application, all operating over the local network. Text chat uses the same UDP socket infrastructure as voice, keeping the implementation consistent across features. User state (login, contacts, history) is managed via SQL Server, making the application stateful even across sessions.
UDP-based peer-to-peer messaging with 1,500-byte datagrams. Messages are
sent via Socket.Send() and received asynchronously through
BeginReceiveFrom() callbacks — keeping the UI thread
unblocked. Displays sent/received messages separately. Enter key shortcut
supported alongside the Send button.
Custom Wave audio engine built from scratch — no NAudio or external
libraries. WaveIn.cs and WaveOut.cs wrap
Windows Multimedia API (winmm.dll) via P/Invoke with native
structs: WAVEFORMATEX, WAVEHDR, and
WAVEOUTCAPS. Audio is captured, buffered, and transmitted
over UDP to the remote peer.
Peer-to-peer file transfer over the LAN using the same socket infrastructure. Files are read, serialised into byte buffers, and sent to the remote IP:port over the local network — no external protocol or cloud upload required. Suitable for documents, images, and other binary payloads within the same subnet.
Binary · Byte Buffer · LAN
Full user account lifecycle — Login (LogInGUI), Sign Up
(SignUpGUI), and persistent contact/chat history via
SQL Server Express. Chat history is loaded from tblChatHistory
on startup, saved per message, and can be fully cleared via a
confirmation dialog. User profile pictures displayed via
PictureBox with custom icon resources.
Two of the most technically involved components are the UDP socket layer
and the custom Wave audio engine. Both are implemented without third-party
libraries — relying on .NET's System.Net.Sockets for networking
and direct Windows API P/Invoke for audio device management.
A single UDP Socket is created at form load, bound to the
local machine's LAN IP and a chosen port, then connected to the remote
peer's IP and port. SocketOptionName.ReuseAddress allows
the port to be reused if the application restarts.
BeginReceiveFrom with an AsyncCallback keeps
the UI thread fully responsive while waiting for incoming messages. When
a datagram arrives, MessageCallBack() decodes the 1,500-byte
buffer using ASCIIEncoding, appends the message to the
ListView, and immediately re-arms the receive loop.
GetLocalIp() iterates the host's address list and returns
the first IPv4 address — automatically populating the local IP field so
users only need to enter the remote peer's IP, not their own.
The audio subsystem wraps the Windows Multimedia API directly through
Platform Invocation Services (P/Invoke). All native structs —
WAVEFORMATEX, WAVEHDR, WAVEOUTCAPS
— are declared in C# with [StructLayout(LayoutKind.Sequential)]
to match the exact memory layout expected by the Win32 API.
WaveIn.cs (16,759 bytes) manages microphone capture:
opening the input device, setting up double-buffering with
WAVEHDR headers, and streaming PCM audio frames into
a buffer. WaveOut.cs handles playback — writing buffered
audio back to the speaker output device on the receiving peer.
MMSYSERR.cs defines the full Windows Multimedia error
code enumeration (MMSYSERR_NOERROR, MMSYSERR_BADDEVICEID,
MMSYSERR_NOTENABLED, etc.) used to validate every API call return
value — providing meaningful diagnostics for audio device failures.
Entry point of the application. User enters credentials and clicks
"Keep Log In" to proceed to the main contacts screen. On success,
instantiates SkypeGUI, shows it, and hides the login
window — maintaining a single active window at any time.
New user registration screen. Collects user details and persists them to the SQL Server database via the BOLayer. Linked from the Login screen via a "Register" or "Sign Up" route — keeping authentication flow self-contained.
Main hub displaying the contact list in a ListView
with dynamically generated contact buttons. Navigates to
ChatGUI on contact selection. Contains the application's
primary navigation logic and serves as the shell for all
sub-features.
The core communication screen: dark-themed (charcoal gray panels,
black input area) with a friend's profile picture and name in orange.
Message history displayed in a scrollable RichTextBox;
incoming messages in a ListView. Local/remote IP and
port fields configure the UDP connection. "Delete History" button
with confirmation dialog.
Socket.Bind(), Socket.Connect(), async
BeginReceiveFrom() with callback, and ReuseAddress
socket option for reliable LAN communication without a central server.
WAVEFORMATEX, WAVEHDR), device enumeration,
double-buffered audio streaming, and the full MMSYSERR
error code enumeration — with no dependency on NAudio or any third-party
audio library.
SqlConnection, SqlCommand, and
SqlDataReader operations — making the UI layer completely
database-agnostic.
Form.Show() /
Form.Hide() transitions, resource-embedded icons and
profile pictures via Properties.Resources, and
chat history persistence with load-on-startup and clear-on-demand.
GetLocalIp()
using Dns.GetHostEntry() to iterate the machine's address
list and extract the IPv4 LAN address automatically, removing the
need for users to manually look up their IP. The remote peer still
provides their IP, enabling direct LAN addressing.
| Language | C# · .NET Framework |
| UI Framework | Windows Forms · Visual Studio Designer · .resx resources |
| Networking | System.Net.Sockets · UDP (SocketType.Dgram) · BeginReceiveFrom |
| Audio | Custom Wave Engine · winmm.dll · P/Invoke · WAVEFORMATEX · WAVEHDR |
| Database | SQL Server Express · SqlConnection · SqlCommand · local .mdf |
| Architecture | 3-Tier · GUI Layer + BOLayer.dll + SQL Server |
| IDE | Visual Studio · Eclipse CDT (audio prototype) |
| Encoding | ASCIIEncoding · byte[1500] datagram buffer |
Full C# solution including GUI, BOLayer, Wave audio engine, and SQL database on GitHub.