Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Author
Message
XFS Illusion
17
Years of Service
User Offline
Joined: 20th Apr 2006
Location:
Posted: 17th Jan 2012 06:30 Edited at: 17th Jan 2012 06:36
This is a simple class I use in a few of my applications. I figured I\'d put it here in case anybody needed something like it. Let me know if there are any problems. It is written in VB.Net and uses system.net and system sockets for communication. Though UDP isn\'t as \"Reliable\" as TCP (So they say), it is for certain much faster and ideal for fast paced games in my opinion. Mainly because TCP checks to ensure all packets are received, and can spend a great deal of time in doing this. But in many games, a person needs to know what is happening then and there, without needing to double check what happened 10 minutes ago. However, depending on how it is used, it can be just as reliable, if a person is willing to make the effort to verify important packets of information.

Listen(port): Opens a port and starts listening for incoming messages in a separate thread.
IsListening: Returns true if the object is listening.
StopListening: Stops the listening thread.
Send(string,ip,port): Sends a data-gram in the form of a Byte to the specified location.
ListenStream: Where the data received will be stored on each pass.

Here is an example of a simple Console based server:


Note that UDP is connectionless, so I usually create a \"Handshake\" routine to get the IP/Ports and other information from the clients that i\'m communicating with. I\'ll generally store this information into an array upon first connecting so that it can quickly be recalled when needed.

I had actually wanted to make this a plugin for Darkbasic Professional, but I\'m not sure how to convert a dll created in vb.net for use in DBP. There was a good article in the DLL Talk forum, but all the links within in are pretty much dead. If somebody has some insight into this, i\'d love to hear about it.

Attachments

Login to view attachments
MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 17th Jan 2012 08:04
Hands on Dark Basic book two explains how to setup custom DLLs for DBPro if that helps...

So this is for?

XFS Illusion
17
Years of Service
User Offline
Joined: 20th Apr 2006
Location:
Posted: 17th Jan 2012 21:11 Edited at: 17th Jan 2012 21:12
Multiplayer Games in .NET.

Login to post a reply

Server time is: 2024-04-18 14:52:55
Your offset time is: 2024-04-18 14:52:55