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.

Newcomers DBPro Corner / probs with displaying recieved net messages

Author
Message
holger at home
17
Years of Service
User Offline
Joined: 22nd Jun 2007
Location:
Posted: 22nd Jun 2007 10:42 Edited at: 22nd Jun 2007 14:17
hey there

I'm learning how to program a multiplayer/chat function in Hands ON Dark Basic Vol.2 right now
Setting up a TCP/IP connection works well but recieved messages arent displayed immediately after sending.
Only after the reciepient sends a new message to the other player, then the recieved message prompts.
The way the code looks like and so far i understand it, i did expect it to be displayed for the reciepient immediately the message has been sent.
To me as a beginner the code seems so pretty clear and logical
as well it isnt explained more in this book.
So i have to ask : is this the only way how a "chat" can be made
in dbpro? Or do i have to program it in another way?
Have to say: i use the IP: 127.0.0.1 to get access to the "host" on my own pc. (cant imagine but maybe thats the reason?)

so may i please you for help any advices or maybe tuts ?
(because i didnt found any else nowhere about programing a chat?
and i'm out of any idea how to change it)
previosly so many thx for your effords
hope to read you soon ]

Here's the code:

TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 22nd Jun 2007 21:08 Edited at: 22nd Jun 2007 21:10
127.0.0.1 is not the machine's IP address - it's the loop-back address.

The server program should be set to the IP address of the machine it's running on.

The client program should be set to the IP address of the machine it's connecting to.

Tutorial 13 here covers the server side:

http://forum.thegamecreators.com/?m=forum_view&t=99497&b=10

TDK_Man

holger at home
17
Years of Service
User Offline
Joined: 22nd Jun 2007
Location:
Posted: 23rd Jun 2007 09:44
heya TDK_Man
thx for your reply and your link to the tuts.
although i do have both volumes of Hand of Dark Basic it's worth to work them also out. Because i would say basically there are all commands explained but you will be rushed through all the chapters.

To your tips: I'm using the back loop IP:127.0.0.1 only to check if a connection is established on my own pc.

The server IP is to define in the function getipadress$()
after declaring if the players machine shall be
the host or client hostorclient().

So do you think it depends on the back loop IP that a message is only displayed for the recipient after sending a message?

Since my first post i made a change in the main loop:
I added the following lines immediately before the:
while net message exists() command:
repeat
get net message
until net message exists()
while net message exists()
print net message string$()
get net message
endwhile

I do not really know why but it fixed the prob that some messages arent displayed and some messages are displayed for 2 or 3 times.

Unfortunately i have to wait until my friend fixed his pc
after installing vista hehe

so long holger
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 25th Jun 2007 04:55 Edited at: 25th Jun 2007 04:57
I have not dived into the DBPro networking as yet - but I know TCPIP programming well enough that I wrote a web server that is faster that IIS, Apache, and Lighttp webs server softwares.

Typically for games something called UDP packets are used usually. Basically you send a "packet" out there - and there isn't a guarantee it'll get there. (I say this because the other way does guarantee it gets there (sorta) but is slower for things like multiplayer where a constant stream of "player coordinate update" packets are sent.

Assuming you are using UDP Packets, you need to constantly be checking for the arrival of a packet in your main loop - only sending a packet when you have one ready to go naturally, and constantly polling to see if something new came in.

Typically there are senders and listeners. So for a two way communication you need to have one of each.

Hope this guides in the right research direction to help toward finding a fix.

Jason

Know way to many languages - Master of none
ThinkDigital
19
Years of Service
User Offline
Joined: 18th Aug 2005
Location: A galaxy far, far away...
Posted: 25th Jun 2007 09:57
If you want to use UDP for DBpro, you'll need the Tempest DLL (look in the Program Announcements) or something similar. DBP does only TCP.

"Variables won't, constants aren't."
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 25th Jun 2007 13:39
@Think digital: Cool. That also makes me smaile because you just reminded how easy it is to expand DBpro with your DLL's if you choose. That's something I'm definately capable of doing

I wonder if I couldn't add multithreading "helpers" and the like to make games smoother, I know I could make a DirectX browser of sorts - hmm... to much on my plate right now but I do like DBPro.

Jason

Know way to many languages - Master of none
ThinkDigital
19
Years of Service
User Offline
Joined: 18th Aug 2005
Location: A galaxy far, far away...
Posted: 25th Jun 2007 23:22
Quote: "I wonder if I couldn't add multithreading "helpers" and the like to make games smoother"


Multithreading "helpers"? There is no multithreading in DBP, as far as I know - or do you mean a DLL that allows multithreading?

"Variables won't, constants aren't."
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 26th Jun 2007 01:17
The Latter. I mean, I'm not sure how I would or why I would - but I'm no stranger to writing multi-threaded applications in FreePascal - Which is the kind of "programming level" as C++. I can make DLL's that do just about anything - the trouble would be handle syncronization with a program that only is (for us anyway) single threaded.

Perhaps of use would be a separate thread for handling multi-player - so the main loop of DarkBasic would simply shoot out the latest coord's, then the other "thread" would handle the lan while the game was plugging away. I'm talking off the cuff - haven't thought this through - and to be honest - at this point - I'm just trying to find the combination of "gfx tools" that allow me to make decent levels without to much headaches so I can reasonable results - reasonably fast - so I can concentrate on the game play programming

(At least for now!) I also just got the Dark GDK/SDK so I have PLENTY of experimenting and such to do before I go trying to add anything.



Jason - Good Day All!

Know way to many languages - Master of none

Login to post a reply

Server time is: 2024-11-25 15:46:34
Your offset time is: 2024-11-25 15:46:34