Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

TCP Library Framework for serialized data objects transfers

Project
An easy to setup tcp based server/client concept that acts as a framework on top of the existing tcp functionality of .Net

Demonstration of multiple connections, sending data and latency/uptime computation
[Image: DaLbPYM.png]

Goal
Allowing to send serialized objects or files in both directions and for easy use front-end

Details
  • Client/Server interaction is Event driven
  • Uses queues for handling data to not excessively flood a connection
  • Uses constructed packets as communication
  • - Uses compression of payload data
  • - Performs a checksum for each payload
  • - Performs a protocol version check (handshake)
  • Uses so called 'Heart Beat' packets to keep alive and measure latency
  • Contains a centralized config where all settings can be changed



The Event handling explained

The event handling of both instances, client and server, can be assigned to a single method,
the arguments given have a base class that are the same, however the server and client do not share the
same functions and properties of a given EventArg object.

The TcpEvent holds what is happend and the EventArgs holds the included arguments with that event
This way we can use a 'Select Case' construction to make life easy.
Code
Private Sub Event_Status(Type As TcpEvent, EventArgs As TcpEventArgs)

End Sub


To determine who's event we have the TcpEvent has the following functions to find out
Code
EventArgs.IsFromServer
EventArgs.IsFromClient


After determine who we dealing with its time to cast our sender
Code
Dim args As ServerEvent = CType(EventArgs, ServerEvent)
- or -
Dim args As ClientEvent = CType(EventArgs, ClientEvent)


Remarks
The server assigns each connected peer a unique ID, this is done to have a fixed reference to a specific connection.
All operations are multi threading, direct Event to GUI operations have to be made cross thread save.

Example for a file transfer from server to client:
Code
Me.Server.SendFile(args.Client,"..\somepath\file.ext",<optional transfer ID>)

And from the client side to receive:
Code
Dim args As ClientEvent = CType(EventArgs, ClientEvent)

If (args.Packet.ContentType = ContentType.File) then
    args.GetAttachement.SaveAs("..\somepath\" & handler.GetAttachement.Filename)
End If



Sending objects across the pipeline

Code
Me.Server.Send(handler.Client, ContentType.SerializedData, "Welcome!")

Me.Server.Send(handler.Client, ContentType.SerializedData, true)

Me.Server.Send(handler.Client, ContentType.SerializedData, Math.PI)

Me.Server.Send(handler.Client, ContentType.SerializedData, New Byte(){})

We can basically send anything we want but there is a catch to this concept, if we decide to send a custom object,
it be a structure or class it HAS to be a known reference type for both sides. Thats why i use this Protocol as middle man.
Define you custom objects in there which is then released with the client itself.


Remarks
Transfer of files have a so called ID (As Object) which is used to identify this file for a certain reason, it can be number or string , etc,
as long as this ID object can be serialized everything is fine.


Send content flags explained
Code
Public Enum ContentType As Byte
    Synchronize = 2
    Acknowledge = 4
    Handshake = 6
    SerializedData = 8
    File = 10
End Enum

The first three flags are only used for the protocol to identify itself to another, not used for our purpose.


Safety

The server has a minimal protection, it does not use encryption however this is easily achieved since we (you) control the payload, all what the Framework does is sending it over a controlled connection.
It does contain some minimal safety features such as a maximum buffer overflow limit and protocol version vertification.
If any client, it be new or accepted, over steps these limits, the server drops the connection immediately, if a packet
is not the way it should (think of checksum or not able to construct the packet) it will drop the received data.
(Default values, 5mb max per payload and protocol version is changeable in the config)

Lag and Latency

The server maintains a threshold latency, if a client is too slow or simply not responsive it will drop the connection.
(Default value i use is 30 seconds)

Final notes

I include the demo app that demonstrates how to use it, if you got a question post them.
If you don't understand the workings of TCP connections, im not trying to be rude, but i am not going to explain that.
I assume you know how this works and i give you this source to extend your effort with your goal in whatever project you are developing.

Source:
- Version: A2 https://dl.dropboxusercontent.com/u/8007...a2.src.zip
- Version: A1 removed

Those that see in the right place, know. Keep that in mind :)
I still need to look over this, but will look at it later.
It looks like you but in a lot of effort into this project.
Would change the download and not have dropbox since after awhile it will remove it if too many people download it. Post it on your github would help your portfolio. or here is the zippyshare http://www61.zippyshare.com/v/H78llKFQ/file.html
(Jan 18, 2017 01:53 PM)SIM-1847363 Wrote:  I still need to look over this, but will look at it later.
It looks like you but in a lot of effort into this project.

Somewhat, its about month work i think. :)
Please consider using Github for your releases in the future.
And it looks really nice, great job! :)
(Jan 18, 2017 02:34 PM)Ninja Wrote:  Please consider using Github for your releases in the future.
And it looks really nice, great job! :)

I made the github, but i cannot update the thread itself, so ill have to reply with the link.
This looks really nice! And I would second using github, much easier to read and make changes to.
Seems i can no longer hide what i hoped to keep on a down low, and you young lads pushing for it.

https://github.com/TheBarret/Tcp.Framework
(Jan 19, 2017 03:11 PM)Barret Wrote:  Seems i can no longer hide what i hoped to keep on a down low, and you young lads pushing for it.

https://github.com/TheBarret/Tcp.Framework
BARRET!!!! I missed you, my man. Got tired of Rocket League? I am really happy you're back.
(Jan 19, 2017 04:30 PM)SIM-1847363 Wrote:  BARRET!!!! I missed you, my man. Got tired of Rocket League? I am really happy you're back.

How the f*** did you know i bought rocket league for christmas? ❓ did you break into my beloved system rig?? 😁
I fucking love the classic windows theme. Or are you actually using Windows 9N?
(Jan 19, 2017 08:11 PM)Ninja Wrote:  I fucking love the classic windows theme. Or are you actually using Windows 9N?

No i have win7 but i like some old things. btw why the *** cant i edit the thread, is that a new update around here ??
(Jan 19, 2017 08:28 PM)Barret Wrote:  No i have win7 but i like some old things. btw why the *** cant i edit the thread, is that a new update around here ??

Maybe because you're not upgraded member.
Oh. Welcome back, TheBarret. 🤝 I love reading your old thread.
I played with the source and have looked through it quite a bit. I love it so far. It's something I'll add to or modify a project with in the future.
(Jan 19, 2017 10:33 PM)Malum™ Wrote:  I played with the source and have looked through it quite a bit. I love it so far. It's something I'll add to or modify a project with in the future.

Yeah sure np, its public domain. if u need help to integrate it let me know.
Nigga you ain't Barret. I bet my money you are an updated version of Only3.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Python] by Luffy-_-Jan 11, 2022 08:14 AM 5 161 Jan 11, 2022 08:14 AM
Last Post: Hackers
[Java] by PsychoJul 3, 2021 11:15 PM 24 1,973 Jul 3, 2021 11:15 PM
Last Post: Lookdadon
[C] by phisnNov 11, 2020 08:44 AM 1 165 Nov 11, 2020 08:44 AM
Last Post: HFDone