Chat Client/Server Part 1: Network Programming Primer and Packet Base Class
Give Us Some Code, Already!
The first thing we are going to implement is the base classes for an extensible protocol, which will be capable through polymorphism of sending any type of packet you can imagine through our network connection. We are going to implement this as a class library, called Chat.
Step 1: Create a New Class Library Project. You should already know how to do this.
Step 2: Create a New Class Source File called Packet.cs. This is going to serve as our abstract base class.
Now, the packet class itself is meant to be a base class for a protocol to implement. So we are going to make it abstract.
Step 3: Mark Packet as Abstract. Modify the declaration of the class to read as follows.
1 | public abstract class Packet |
This means a packet cannot be instantiated all by itself. There must be child class which inherits from packet and implements its functionality. However, all of our protocol library functions are going to use Packet for transferring data, that way they can accept any kind of packet that comes down the line.
Follow Dave on Twitter

[...] See the original post here: Program With Dave » Blog Archive » Chat Client/Server Part 1 … [...]
[...] the original post: Program With Dave » Blog Archive » Chat Client/Server Part 1 … By admin | category: chat software | tags: dot-net, manifest-itself, p2p-video, result, [...]
[...] Address Already In Use: JVM_Bind:8080″. Now, if you’ve read my sockets tutorial network primer, you know that a port can only be bound for listening once. So apparently I had another process on [...]
[...] you have not read Part 1 of this Multi-Post tutorial, check it out now. This tutorial will rely on the code written in that [...]
[...] you have not read Part 1 and Part 2 of this network tutorial series, please do so now. The code in this post will build upon [...]