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.

Program Announcements / New Winsock2.2 Plugin - Free Multiplayer & Network Enhancement Pack for DBPro!

Author
Message
Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 5th Mar 2006 00:56 Edited at: 5th Jul 2007 16:15
new: released unmanaged c++ library! download from my plugins website.
new: 1.2.1 bugfix; mouse_p2p example works. UDP works! everything works
new2: version 1.2.0 released! runtime startcrashs finally resolved! read change-log for further info.


Hi all!

I already announced in the DLL Talk that I had just recently made this easy to use and free Plugin. I would like to present the Plugin now in this Thread, as it might get more attention.

For the originial post go here: http://forum.thegamecreators.com/?m=forum_view&t=73268&b=18
There you will find some benefits about the plugin. You won't be able to answer there though, since it is locked.
The plugin is now in a real safe and secure state, and can be used and tested by you! That's why I actually want your attention; I'd like you to use and test it! As for now I don't see any bugs!

Features
- TCP & UDP support
- 16000+ simultanuous connections (depends on machine)
- new commands allow easy packet management
- allows direct access to packet data
- allows packet creation using memblock
- extended debug information using the debug dll
- faster execution time with the release dll (available on demand)
- extended documentation and help for every single command in there!
- 6 examples
- 1 Tutorial so far

The plugin has 60+ commands so far and is fully documented. You can access the help files with F1 if your editing cursor is above a winsock command. All the commands start with "WINSOCK" to better keep them clustered. There are two server-clients examples included in the help directory, which should help you get started.
The chat server & client is easier to begin with, as it uses the easy command: WINSOCK SEND STRING
If you want to get more advanced, then have a look at the other server&client example included, where you can send packets that you made up in a memblock or memory location.

If you feel stuck read the help files, they might help you get along with the basic errors! And look at the examples in help/examples. Otherwise feel free to post here.


Website
I have put up a website where you find all stuff and links related to my plugins!
http://homepage.swissonline.ch/barnski/main.htm

Download
I have introduced a 3digit version number now.
format: a.b.c
where c is incremented for bugfixes, b for new functions, and a if I extend the dll significantly. I start with 1.0.0!
grab the files from my website (link just above).
read the license agreement please
Note: the debug version is included per default. it shows error messages if you wrongly use the dll. if you want the release dll (faster and smaller in size) ask me.


Online Help
View the full command help list. In the download there are additionally some examples included.
http://homepage.swissonline.ch/barnski/help/winsock.htm

Tutorials
Beginners
The Basics about Winsock http://homepage.swissonline.ch/barnski/Winsock-Basics.html

Oh and before I forget, here's a screenshot of the Chat server & 3 clients in action:


Here is a screenshot of the mouse_p2p UDP example in action:


That's all for now!

The admiral
21
Years of Service
User Offline
Joined: 29th Aug 2002
Location:
Posted: 5th Mar 2006 10:25
Thank you thank you very much ive been looking for another multiplayer plugin that might suit me so ill be testing this out and see if its good. I appreciate anyone who takes the time to make a dll for dbpro.

The admiral
Philip
20
Years of Service
User Offline
Joined: 15th Jun 2003
Location: United Kingdom
Posted: 5th Mar 2006 14:27
This is very good and a significant contribution to the DBP community! Thanks very much!

Cheer if you like bears! Cheer if you like jam sandwiches!
Quote of the week: "... I started learning DBP while I was a Satellite Network Controller for the US Army Space Command ... "
Humanoid
20
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Finland
Posted: 5th Mar 2006 21:09
mayby change example code little



while (not escapekey()) not work correct

i use u6.0b2

Suomi Finland PERKELE!
<AMD athlon 64 3000+> <Asus A8N-E nForce4 ultra> <GF6600LE PCI-E> <1GB ram>
Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 5th Mar 2006 22:49
Thanks for the comments!

Is this "not" bug already reported?
Anyways, I changed the example code in all files to what you posted Humanoid.

next thing I will work on is a little UDP example using memblocks.

-- I just started with DarkSDK, by translating DBP Projects. --
Humanoid
20
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Finland
Posted: 6th Mar 2006 06:07
Great memblock example interesting, i dont know is 'not' bug report yet. maybe.

Suomi Finland PERKELE!
<AMD athlon 64 3000+> <Asus A8N-E nForce4 ultra> <GF6600LE PCI-E> <1GB ram>
The admiral
21
Years of Service
User Offline
Joined: 29th Aug 2002
Location:
Posted: 6th Mar 2006 06:17
So does the server always have to listen for connections??

The admiral
Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 6th Mar 2006 12:59
Quote: "So does the server always have to listen for connections??
"

Usually the server sets one channel into the listen mode (before the main loop), and continues with its execution. In the main loop he will check if the listen channel has received a connection request. If so, then it will create a new channel that will handle the connection. The listen channel will remain open and continue listening for connections. But of course you may close it whenever you want, or open several channels that listen on several ports for con.requests!

I might make a tutorial soon that will cover the basics of winsock connections... it will include server/client and peer2peer networking methods. Stay tuned!

-- I just started with DarkSDK, by translating DBP Projects. --
CattleRustler
Retired Moderator
20
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 6th Mar 2006 17:03
Quote: "So does the server always have to listen for connections??"


usually, thats what a server does

FREE Automatic file updates for your distributed Games and Apps - see Program Announcements Forum - DBP Demo
Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 6th Mar 2006 19:47 Edited at: 6th Mar 2006 19:50
Okay I promised a tutorial:
http://homepage.swissonline.ch/barnski/Winsock-Basics.html
This one is a short and general discussion about Winsock, meant for those who want to learn about it. The next one will be more specific about my Plugin.


@CattleRustler
I've been thinking of supporting your EZserver with some integrated commands, since it would be great for developers to concentrate on the client, and getting the server for free. While your server provides functionality that will suffice in most cases, it will probably only be helpful for beginners, who use the string commands to send packets (I do not expect advanced users to use string commands, as you can pack much more data using direct memory access/memblocks, and therefore reduce the bandwidth enourmously). Maybe you want to improve your server to handle binary data? instead of using seperators you could use a length indicator.. it would really improve the functionality.

-- I just started with DarkSDK, by translating DBP Projects. --
CattleRustler
Retired Moderator
20
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 6th Mar 2006 20:36
Quote: "Maybe you want to improve your server to handle binary data? instead of using seperators you could use a length indicator.. it would really improve the functionality."


Thanks, yes, this was the plan all along (to not rely soley on strings) but I just havent had the time. I have in the past tried to provide a client dll for dbp which would handle all of the parsing etc, but since I dont code in c++ it never came to fruition. In fact the dll was done, handling all features of EZS, and doing remote client management internally in the dll - problem was that the conversion methods to get the .NET dll into usable dbp plugin form was not reliable so I scrapped the project. There have been recent developments that may make these concepts viable again - you and I should talk. Have msn or irc?

FREE Automatic file updates for your distributed Games and Apps - see Program Announcements Forum - DBP Demo
The admiral
21
Years of Service
User Offline
Joined: 29th Aug 2002
Location:
Posted: 7th Mar 2006 06:38
Hmm I tried it out and it seems more complex to use than it should be...cant you simplify it down to send dword or send integer etc commands because all the other dlls do it? Your average programmer isnt going to want to mess around with memory and rading all sorts of values just to get a little bit of data.

The admiral
Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 7th Mar 2006 11:11 Edited at: 7th Mar 2006 11:12
Quote: "Hmm I tried it out and it seems more complex to use than it should be...cant you simplify it down to send dword or send integer etc commands because all the other dlls do it? Your average programmer isnt going to want to mess around with memory and rading all sorts of values just to get a little bit of data."

I have been thinking about how to simplify the usage... Don't fear: at the end of this week I will have implemented a whole new bunch of commands to acquire this task!

Quote: "you and I should talk. Have msn or irc?"

I added you on MSN and sent you an email!

-- I just started with DarkSDK, by translating DBP Projects. --
CattleRustler
Retired Moderator
20
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 7th Mar 2006 17:48
okies, ill be on msn later today

FREE Automatic file updates for your distributed Games and Apps - see Program Announcements Forum - DBP Demo
x1bwork
18
Years of Service
User Offline
Joined: 9th Nov 2005
Location:
Posted: 7th Mar 2006 18:05 Edited at: 7th Mar 2006 18:47
This is very impressive,Barnski.

Barnski && Cattlerustler
Question or request. Is there or could you implement options to switch on and off TCP Flags like SYN/ACK,PSH,URG,FIN,RST

Ive written basic IDS tools in perl for training purposes.
I'd love to write one in DBP using BlueGUI for a frontend and your sockets plugin,just to show that DBP is very capable of doing far more than just game development.

example perl code(this code has been edited to prevent anyone for trying to cause any damage with it):



Opposing force
18
Years of Service
User Offline
Joined: 10th Aug 2005
Location: England
Posted: 7th Mar 2006 19:26
I have a question. Can this plugin work alongside other plugins such as multisync?
The admiral
21
Years of Service
User Offline
Joined: 29th Aug 2002
Location:
Posted: 8th Mar 2006 03:40
Ok thanks thats a releif heh

The admiral
Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 8th Mar 2006 12:27 Edited at: 8th Mar 2006 12:41
Quote: "This is very impressive,Barnski.

Barnski && Cattlerustler
Question or request. Is there or could you implement options to switch on and off TCP Flags like SYN/ACK,PSH,URG,FIN,RST"

Thanks, though I think I can't follow your request. I ve been spending time yesterday to find out how to set TCP flags on packets, but I think there is no way to do so. You know I am using Winsock's TCP protocol, that means Winsock makes up the IP and TCP header. Then all I add is the packet data.. the body. There is no way to change the TCP header in that way.
I could send OOB (out-of-bound) data, but I am not sure if that is what you wanted. Setting TCP flags manually results nearly in the same as coding the whole TCP protocol (unless you want to make DoS attacks).

Quote: "I have a question. Can this plugin work alongside other plugins such as multisync?"

I am not quite sure what you are asking for, I see 3 interpretations of your question:
1. can a dbp program that uses your new winsock plugin communicate with another dbp program that uses another winsock plugin?
-Yes, since my Plugin allows you to access and change all the packet data (while soon providind some easier functions).
2. can I have both winsock plugins in the user-plugins folder of my compiler, and then only use one in my code?
-Yes, I think so. Since the compiler wont link the dll that is not used.
3. Can I use both plugin commands in my code?
-No, I don't think so, and besides, I do not see a reason why to do so. But maybe it works, I am not sure how winsock will react to this (you cannot mix connection commands of course, say, connect with my plugin, and then use anothers plugin to send data on that connection).


Now for the new commands I am planing, here is a sketch of their functionality. Tell me if you don't like somethin.

new send commands:


new receive commands (read commands move read cursor):


Some more might be added, as I see the need for...

Ok, I think that these commands represent the way how you should work with packets. In every packet you will first want to write a byte or two (using the new commands) to specify the type of the packet, so that the receiver (your other program) will be able to identify the packet and know what to do with it/ what data to read from it.

edit: so a sample code to receive data in a program would look like this:


greets,
Barnski.
x1b
19
Years of Service
User Offline
Joined: 19th Sep 2004
Location:
Posted: 8th Mar 2006 13:15
Quote: "(unless you want to make DoS attacks)"


No. Was hoping to write an app that would allow one to craft a tcp packet (as displayed in my perl code) then set the source and destination addresses in the headers to emulate a Blind Spoof.

Just would have been a new type of app for DBP. I do appreciate that you even took the time to entertain the idea. Thanks Barnski.


Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 9th Mar 2006 21:48
Ok guys, I did it. I implemented a whole new bunch of commands, documented them as usual with the html help, and tested them with my new example I have added to the download pack. You can see a new screenshot in the first post. It's a Peer2Peer UDP example that transfers ones Mouse coordinates and draws points... as you can see from the screenshot I had my fun

here the list of 20 new commands:


Oh and I updated the online (the really online) help. You can access it in my first post. You can click on each command to get full help. Maybe this helps deciding whether to download my Plugin or not. Of course the same help and all examples and even the tutorials are included in the download pack.

greets,
Barnski.
Heartless
20
Years of Service
User Offline
Joined: 8th Feb 2004
Location: Phoenix, AZ
Posted: 13th Mar 2006 01:08
Working from the examples, etc, I've noticed that I can't specify a specific address to bind a listening socket/channel to. Creating a listening UDP socket seems to default to 127.0.0.1, which isn't too useful for receiving remote data. Am I correct in my guess that you test these locally on the same machine? Could you modify 'create udp channel' to listen to '0.0.0.0' by default, and/or accept a parameter to specific the specific address to open the channel on? A machine with multiple network interfaces and addresses could then specify which specific address to listen with.

This is the only caveat I've run into so far, nice work. =)
Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 15th Mar 2006 12:19 Edited at: 15th Mar 2006 13:09
Thanx Heartless.

I just released a new version, where you can optionally specify a local host adress, and it defaults to "0.0.0.0" now.

If you specify a local host adress of "127.0.0.1" or "localhost", then your server will be only accessible from your machine.

If you specify your LAN-address, then your server will only be accessible from within the LAN.

If you don't specify or explicitly set it to "0.0.0.0", then your server should be accessible from anywhere.

If you specify your internet-address (IP), then it will only be acessible over the internet (I think). This may not be possible though if you are behind a router (because your machine has a LAN-ip).

Along with that I fixed some minor issues, and, I made the command "WINSOCK DELETE CHANNEL" to be executed in constant time. unlike the DBPro object deletion commands, this command now deletes a channel equally fast even if you have thousands of them.
However, if you d like to delete all channels, you might just want to use WINSOCK MAKE again to reinitialize winsock (and automatically delete all channels before that).

I hope you can test my plugin again, especially my examples, as I only did test the server.dba and client.dba.
I have not tested the UDP example with my new changes, and nor did I test it over the internet.
If anyone could do this and report whether it works, that would be great.

I think it should work now

edit; when creating an UDP channel, it is not bound to anything! You have to specifically use the WINSOCK BIND CHANNEL command to bind it. This is optional because a client does not need to bind it to a port, only the server. If it should turn out that it does not work over the internet, please notify me

greets,
Barnski.
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 15th Mar 2006 12:43
Quote: "If you specify a local host adress of "127.0.0.1" or "localhost", then your server will be only accessible from within the LAN"

Actually, localhost will only allow connections on the same computer, because it doesn't go through any network interface.

Tempest - P2P UDP Multiplayer Plugin - 70%
Download the free version
Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 15th Mar 2006 13:08
lol thanx benjamin, it must be the exam I am writing in an hour that confused me

I will edit this now, since it is meant as a reference.

greets,
Barnski.
Dextro
19
Years of Service
User Offline
Joined: 26th Feb 2005
Location:
Posted: 16th Mar 2006 19:14
Great plugin!
By the way, can I send packets/establish a connection with the client using the native commands to a server using the dll?
Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 17th Mar 2006 00:30 Edited at: 17th Mar 2006 00:34
@Dextro

The native commands in DBPro use DirectPlay.
Because the DirectPlay protocol is layered on top of the UDP protocol, it would theoretically be possible to use my plugin to communicate with directplay. However, I would not recommend you to investigate into this any further, since it just doesn't make sense. It's like forcing a sphere in a hexagonal cylinder...

I suggest you use my winsock plugin exclusively, as it replaces all the native dbpro commands (if ur missing something, tell me), and allows you to go even further.
I do understand though that the big amount of commands in my plugin threaten most people... but the clear benefit of it is the power you get over the networking, and, you are in full control of things.
You just may need to dive into the materia, and learn abit first about winsock, but it will surely pay off, since what you learn using my plugin will be generally valid for networking altogether.

greets,
Barnski.
Dextro
19
Years of Service
User Offline
Joined: 26th Feb 2005
Location:
Posted: 17th Mar 2006 01:37
Thanks for your reply.
I have some experience with winsock, used with visual basic; but my main concern is about using memblocks with your plugin.
As far as I understand, you can create a "memblock" packet with the WINSOCK ADD XXX command, and send it with WINSOCK SEND TCP PACKET, but what I could not understand, is how you recieve them and read them.
Perhaps you could shed some light into this topic?
Again, thanks for your help, and thanks for the plugin.
Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 17th Mar 2006 15:35 Edited at: 17th Mar 2006 15:37
That's not too complicated:

Packet creation
1. make the packet
2. fill the packet with your bytes
3. send the packet

Packet receival
1. recv message (allows channel to store the data)
2. split data into packets
3. while packet count()>0 do...
4. fetch packet (removes first packet from list and you will now operate on this packet)
5. get the bytes in the packet.
6. return to step 3 if packet count()>0


to see the specific commands in action, you can have a look in my mouse udp example (just replace the WINSOCK SEND UDP PACKET with WINSOCK SEND TCP PACKET)

As soon as I have more time (currently I am working on my Lua Plugin), I think I will write another tutorial. But I hope this brief summary helps to get you started!

greets,
Barnski.
Dextro
19
Years of Service
User Offline
Joined: 26th Feb 2005
Location:
Posted: 17th Mar 2006 17:08
sorry, couldn't find a link to your mouse udp example, so my question is, what if my message is larger than 255 bytes?
As far as i understand, split data will split my message into 255 byte packets, so let's suppose i send a message structured as 100 floats, 2 words and 1 byte, how would I read them if they are splitted?
Thanks again and sorry for my dumb questions.
Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 17th Mar 2006 19:58 Edited at: 17th Mar 2006 19:59
@Dextro
Your questions are not dump at all. This is indeed a draw back when using the integrated commands. The reason for the packet length to be limited to 255 bytes is that every packet will have a length indicator stored in ONE byte, and therefore this value can not be larger than 255. I decided to do so because MOST packets do not require a more space. therefore a length indicator of 2 bytes would be a waste of bandwith in most of the cases! (I am thinkin of a MMORPG server now, as I always did when designing this plugin, where speed and bandwidth is a crucial thing)

Now this limit is actually no limit at all. If you happen to have to send a longer packet, then just split it into two different ones by your self! You will see that this is a rather rare case, e.g. when transmiting a player's character information upon login.

However, with my plugin you can code your own "packet" setup, by avoiding the packets command and using the other: WINSOCK SEND MESSAGE. With that command, my plugin will not send ANY other information than what you specify. Keep in mind though that you cannot mix these two sending ways!

edit: The examples can be found in the download pack: help\examples\winsock\

greets,
Barnski.
Dextro
19
Years of Service
User Offline
Joined: 26th Feb 2005
Location:
Posted: 17th Mar 2006 20:58
Alright, so let me get this straight.
If send a "message" consisting of 7650 bytes, it will be fragmented into 30 packets?
Also, if i send a packet of, lets say, 3000 bytes, it would be splitted into 11 packets of length 255, plus 1 of 195 bytes? Or all the packets will be of the same length?
Lets suppose I send a message with a length of 64 floats, which is equal to 256 bytes, How would I read the last float in the message?
Wouldn't it be fragmented?
Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 18th Mar 2006 00:44
It is not fragmenting it automatically for you. If you add more bytes than 255 to a packet it will cause an assertion (error message), when using the debug dll I provide.

But lets assume you want to make file transfer, then you will definetly not use the packet commands, but my other ones! WINSOCK SEND MESSAGE lets you send up to 8192 bytes at once.

I haven't tried file transfer yet to garantuee that it works nicely. So I will perhaps test this and make an example.


So back to your question: if you want to send a "message" consisting of 7650 bytes, and want to use the packet commands (you have to decide which commands you use for a connection, because you cannot mix them), then you have to manually split it up into 30 packets, each packet's first byte having an apropriate header byte, indicating what packet type we are dealing with...


Actually, fragmentation which you are talking of, is a serious problem, when it comes to overflowing the receive buffer of a channel. the receive buffer grabs up to 8192 bytes, but if, for any reason, there is waiting more, then it will fragment the last packet. THIS is a problem because I haven't taken measures to prevent this.
Normally this will not occurr (as an excuse I could say you need to program your connection better), but in the long term it is best if I add a mechanism to make sure fragmentation is impossible.

I will see how soon I can address this.

greets,
Barnski.
Dextro
19
Years of Service
User Offline
Joined: 26th Feb 2005
Location:
Posted: 18th Mar 2006 02:41
Thanks for your response, but I'm all confused lol. I guess this is what I get for programming with python.
Ok, so I can receive a message of over 8192 bytes, and I can read it without splitting the packet using WINSOCK BYTE for example?
Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 19th Mar 2006 20:41 Edited at: 19th Mar 2006 20:43
Nope winsock read byte is only for usage in cnojunction with the packet commands.

To read the data directly you have to access the memory directly.

WINSOCK RECV MESSAGE (channel)

ptr as DWORD
an_integer as Integer

ptr = WINSOCK CHANNEL DATA PTR(channel)

an_integer = *ptr
inc ptr, 4
an_integer2 = *ptr
...

edit or, on a byte per byte base:

a_byte as BYTE

a_byte = *ptr
inc ptr, 1
a_byte2 = *ptr
...

This is direct memory access... and you may not exceed the data len: WINSOCK CHANNEL DATA LEN. else you could cause a segmentation fault. I may be making it possible to make a memblock to copy the bytes in....
but at the moment I am not having much time. this week Im writing 2 exams, and after that I plan to go on holidays

but we will see...

Oh and.. there is a new update. make sure to download the new version, instead of getting the one in your web browser cache.

Dextro
19
Years of Service
User Offline
Joined: 26th Feb 2005
Location:
Posted: 20th Mar 2006 03:25
Thanks again for your response.
As time passes, more questions arrive, and i have a handful of them right here
Well, first, what is a channel? (sorry for this dumb question, but I'm used to program network stuff with python, and to tell you the truth, I haven't seen that term before. I make mostly hacks and buffer overflows to test our own software.)
As I understand it, I need to use the udp protocol for most of the multiplayer-type games. What I don't understand clrearly is how do I send a message to a specific ip address? What if i want to send it to all the clients at once? Would I have to use a for loop SEND UDP MESSAGE client, ptr, len?
Second, to use the set channel target, i need to know the hostname of the client I need to send it to. That means that first I have to listen on a TCP server, when the client connects pass it's hostname and port to a variable, close the tcp connection, connect client to udp server, ... then set target channel (random channel), variable, variable2?
I guess i have all this questions 'cause i don't know what a channel is, lol.
Sorry for all the questions, but I'm pretty interested in this plugin,
Thanks again,
Billy.
Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 21st Mar 2006 12:25 Edited at: 21st Mar 2006 12:31
Have you read my tutorial about the basics of winsock? there I explain briefly what a channel is. you can find it either in my first post above, or in the download->help folder.

If you want to send a udp message to all clients at once (usually the server needs to do this), then you have to make a for loop, as you said.

When a udp message arrives, it holds automatically the address of its sender. so you can just reply to it (you don't need to call SET CHANNEL TARGET). so there is no problem for peer2peer udp (see my mouse example).


However, it seems that you just found something I haven't thought about yet. if you make a UDP server, then you need to get the remote address into a variable, because the server uses only 1 UDP channel for n clients. that means you have to set the channel target before sending things. But I need to investigate further into this. Me personally, I have only used TCP server/client so far. I never made a UDP server and haven't thought about the issues that arrise . its more complex than a TCP server actually.

so I will add a function that allows you to get the senders host address.
And I will recheck UDP functionality.

edit;
I think the UDP socket (channel) works like this:
when you call recv message, then only a message from one sender will be returned. and after that you should retreive the remote hostaddress. then check whether there is more data waiting, and repeat the same...

Impreza
21
Years of Service
User Offline
Joined: 7th Nov 2002
Location:
Posted: 21st Mar 2006 22:06
please make this dbc compatible

set mipmap mode 1: set matrix texture 1,1,1: set spot light 1,0,90: set normalization on: sync rate 0: statistic(1): flush video memory
autocam off: always active on: hide mouse: set window on
Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 21st Mar 2006 22:50
I don't have DBC nor do I know what to do to make it compatible.

But if DBC is able to load a dll and call dll functions, then you can just use this string table to find out the names of the functions.

syntax of string table entries:
DBP_name % arguments % DLL_FUNCTION_NAME % description_of_arguments

You need the DLL_FUNCTION_NAME part to call the function directly.
use the description of arguments or the help to find out which arguments are needed.

here is the table:


I hope DBC can load dll's...

Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 21st Mar 2006 23:01 Edited at: 21st Mar 2006 23:18
Quote: "this week Im writing 2 exams, and after that I plan to go on holidays "

I hear that. Just got finished writing 29 pages myself.

I'm trying to convert my java program and having some trouble sending data. It might be the way i'm trying to use pointers.
Here's the error I get:
Error in recv_message. recv returned: -1

[edit]
problem with my string length, fixed.
proper length of the expected message is now sent, but server timesout. What I need to send is "FLAPONrnrn", 10 characters. (4 escape characters, )


I'm expecting to receive 10 bytes, and should as long as the string is being sent properly.

I just need to output a string as a series of bytes. If I try to use "WINSOCK SEND STRING", then I don't get any server response.


I believe its to be sent out in big-endian. I'm a java guy, not pointer friendly.

The data to send is correct, as i've got this working in java just fine. Ideas?




[edit]
it finally hit me, i wasn't resetting the pointer's location back to the beginning. problem fixed.


Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 21st Mar 2006 23:37
The error you get just indicates a forceful disconnection from the server (server closed connection).
I have changed the error code information, such that it is more informative (-1 is just general socket error, but there is always a more specific code, which I have forgot to add here). But not uploaded yet.

Now to your code and problem:
I read your source but can't find any obviuos mistakes. I will recheck it tomorrow (evening), and try whether it is the way DBP handles pointer assignment.
Besides, it was very nice to read your code, nicely structured and commented! thanx

Quote: "I believe its to be sent out in big-endian"

this does not affect the message data you send. its just the header data that has to be translated from little- to big-endian. but this is done by winsock. (except of course, if your server reads binary data from what you send him, and if he uses a big-endian system) but since you send strings (byte-sequence), it is not necessary to revert anything..

Quote: "If I try to use "WINSOCK SEND STRING", then I don't get any server response."

That is strange, since I can't see a reason why my plugin should treat the binary data sequence differently as the string (its the same in memory actually, with the slight difference that the string is 0-terminated, but this 0 will not be transmitted).
It could be that DBPro cuts out the 13 10 13 10 in the string... I will test this tomorrow, and hopefully provide a solution

Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 22nd Mar 2006 03:58 Edited at: 22nd Mar 2006 03:59
I found what the mistake was (see edit above)
But a new problem now. My program silently crashes.

Here's the error report
Quote: "[COMMON]
PathToEXE=Cark Basic SoftwareDark Basic ProfessionalProjectsCrashOn_03_21_06.txt
[CEXE]
m_dwRuntimeErrorDWORD=Internal Code:0
m_dwRuntimeErrorLineDWORD=221"




Here's the involved code; line 221 is "WINSOCK SEND MESSAGE channel, buffer, size" inside the sendDataFrame() function.




The particular string i'm sending has to send the null character at the end.

p.s. Don't bother running the code, there's several steps prior to this one before the server will respond to this.


Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 22nd Mar 2006 13:10
You might want to use the DBPro memblock commands to add data to memory. When you are done you can simply use GET MEMBLOCK PTR and pass it to the dll.

hm I don't see why your program crashes.. I added you to MSN, if you like you can send me a msg when you come online and we can look at it together; I could send you a more detailed debuging version for winsock send message, to figure out where it crashes.

Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 23rd Mar 2006 03:43
I used a memblock to create the frame instead, and it stopped the crash on the send. Now just gotta fix the error returned


Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 23rd Mar 2006 18:31 Edited at: 23rd Mar 2006 18:34
Ok, that means that the error was either the length provided, or that dbpro did not handle your pointer commands as you wanted it to.
since there is no difference for the dll whether you provide a ptr to a memblock or a memory area.

I have uploaded a new version that now indicates a more precise error number.

The list of error codes can be found on the msdn library, here is a link to the error table: http://msdn.microsoft.com/library/en-us/winsock/winsock/windows_sockets_error_codes_2.asp

Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 24th Mar 2006 08:07
Thx. Error: 10054 (connection reset by peer)

It's not accepting my login command, but its nothing to do with your DLL. Only thing I can think of at the moment null character that I need to have on the end of the string.


Dextro
19
Years of Service
User Offline
Joined: 26th Feb 2005
Location:
Posted: 29th Mar 2006 22:16
It seems you can't send floats, I can send and receive dwords pretty well, but when I send a float, the server doesn't get it as a float, it parses it as a big dword.
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 29th Mar 2006 23:10
Oh yea, I believe there was an issue with floats and pointers.


Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 3rd Apr 2006 01:06
You are right, test this code, it proves that DBPro doesn't read / write floats, double float, nor double integer correctly:


I post this in the bug forum now.

Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 3rd Apr 2006 18:56
Well, Lee answered that DBPro is not meant to support that kind of memory access, it's thus not a bug.

Hence I made a new command, which allows to copy the channel data directly into a premade memblock.

WINSOCK COPY CHANNEL DATA a_channel as Dword, memory_ptr as Dword

I updated the server-client examples with the 1000 < connections to show case it.
Here a little howto:

1. recv channel data as usual, if channel data is waiting.
2. make memblock with channal data len
3. call WINSOCK COPY CHANNEL DATA with memblock ptr!
4. read from the memblock the desired data...

here the code:


this code is just to illustrate how it would work in general. You can increase performance by for example having a global memblock that is large enough. So that you don't have to create it and delete it all the time.

I have updated the help and client-server example. Tell me if you feel unsure about something..

Dextro
19
Years of Service
User Offline
Joined: 26th Feb 2005
Location:
Posted: 4th Apr 2006 03:55
Works perfectly,
Thanks Barnski.

Login to post a reply

Server time is: 2024-04-19 02:39:32
Your offset time is: 2024-04-19 02:39:32