![]() |
|
[.NET] TCP Library Framework for serialized data objects transfers - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [.NET] TCP Library Framework for serialized data objects transfers (/showthread.php?tid=5527262) Pages: Pages
1
2
|
TCP Library Framework for serialized data objects transfers - Barret - Jan 18, 2017 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 ![]() Goal Allowing to send serialized objects or files in both directions and for easy use front-end Details
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)To determine who's event we have the TcpEvent has the following functions to find out Code EventArgs.IsFromServerAfter determine who we dealing with its time to cast our sender Code Dim args As ServerEvent = CType(EventArgs, ServerEvent)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)Sending objects across the pipeline Code Me.Server.Send(handler.Client, ContentType.SerializedData, "Welcome!")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 ByteThe 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/80079322/TcpFramework.a2.src.zip - Version: A1 removed Those that see in the right place, know. Keep that in mind :) * - SIM-1847363 - Jan 18, 2017 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 * - Barret - Jan 18, 2017 (Jan 18, 2017 01:53 PM)Kevin. Wrote: I still need to look over this, but will look at it later. Somewhat, its about month work i think. :) * - Ninja - Jan 18, 2017 Please consider using Github for your releases in the future. And it looks really nice, great job! :) * - Barret - Jan 19, 2017 (Jan 18, 2017 02:34 PM)Ninja Wrote: Please consider using Github for your releases in the future. I made the github, but i cannot update the thread itself, so ill have to reply with the link. * - debug - Jan 19, 2017 This looks really nice! And I would second using github, much easier to read and make changes to. * - Barret - Jan 19, 2017 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 * - SIM-1847363 - Jan 19, 2017 (Jan 19, 2017 03:11 PM)GrimEdittion Wrote: Seems i can no longer hide what i hoped to keep on a down low, and you young lads pushing for it.BARRET!!!! I missed you, my man. Got tired of Rocket League? I am really happy you're back. * - Barret - Jan 19, 2017 (Jan 19, 2017 04:30 PM)Kevin. 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?? 😁 * - Ninja - Jan 19, 2017 I fucking love the classic windows theme. Or are you actually using Windows 9N? * - Barret - Jan 19, 2017 (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 ?? * - Rhez - Jan 19, 2017 (Jan 19, 2017 08:28 PM)GrimEdittion 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. * - Malum™ - Jan 19, 2017 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. * - Barret - Jan 19, 2017 (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. * - SubGenius - Jan 20, 2017 Nigga you ain't Barret. I bet my money you are an updated version of Only3. |