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.

DarkBASIC Professional Discussion / Broken network commands ?

Author
Message
Shadowfax
23
Years of Service
User Offline
Joined: 20th Jan 2003
Location:
Posted: 9th Jul 2003 16:53
Hiyas folks

Just trying some multiplayer code. I can get a session set up all ok but seem to have problems sending and receiving packets

PROBLEM 1:
I send string packets to player number 0, so should reach all players but doesnt (have tried integer packets too)

PROBLEM 2:
when using the net message string() command i get 'Error #100001: Could not determine parameter type of 'net message string()'

I have tried 'net message string' command with and without parentheses, getting the same result with both *and* have tried 'net message string$()' but this does not get recognized as a system command

Am using DBPro with Patch 4.1
I tried the alternatives as there is a 'net message string$()' command listed in the index of the help files along with a 'net message string()' command

Help anyone please ?
"No Gir ... thats BAD !"
Shadow Robert
23
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 9th Jul 2003 17:02
lmao... i love your siggy
as soon as i can get my system to connect to others... i'll try to find out whats wrong (tried the multiplayer stuff earlier and it was all like not wanting any of it)

Shadowfax
23
Years of Service
User Offline
Joined: 20th Jan 2003
Location:
Posted: 9th Jul 2003 17:22
I can get a session up and running ... like i msg'd to dalmonar who is also having mplyr probs ... its more than possible to compile the code to a 640*480 window and then have two instances of the program running on the same machine .... they both see each other and i can get the session working ... thats when i hit the probs though


All hail Zim

PS i would post code but for what ever reason the msg server kicks out when i do

"No Gir ... thats BAD !"
shwuckie
23
Years of Service
User Offline
Joined: 9th May 2003
Location: Australia
Posted: 9th Jul 2003 18:02
ok this is how i used do it. to send a string the command is:

send net message string var,string$ (a la the manual)

and to process a recieved message i used :

msg$=net message string$()

(dont forget to get the packet ready for processing first with GET NET MESSAGE)

but now i dont use that at all, now i convert everything i send (intergers and strings etc) into memblocks and just send receive memblocks cause i can mix n match and send all info in one packet that way oh yay!)

hope that helps mate

optic blast! megablast! have a blast!!
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 9th Jul 2003 20:30
Here's some code I kept when I helped out someone else with the multiplayer commands (I forget who it was).

There's a hard-coded IP address in there somewhere that you'll either need to change or use my local-ip-getter code - if you need it, just ask
heartbone
23
Years of Service
User Offline
Joined: 9th Nov 2002
Location:
Posted: 9th Jul 2003 22:24
IanM inside your 'ip getter' code is this fragment

p=HostInfo+12
p=*p
p=*p
p=p+(index*4)
ip=Call Dll(DLLNUM,"inet_ntoa",*p)

where : HostInfo= Call Dll(DLLNUM,"gethostbyname",MEM256PTR)

Can you explain why you set the pointer of a pointer?
Can this DLL call be done in DarkBASIC classic (enhanced)?

The more you see, the more you know.
The more you know, the more you see.
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 10th Jul 2003 00:11 Edited at: 10th Jul 2003 00:11
It's because the field I needed to access in the HostInfo structure is defined as a pointer to an array of pointers to ip-addresses.

So the first line gets the top level pointer.
The next line gets the pointer at the top of the array of pointers.
The next line follows the pointer to get the address of the address list.
The next line adjusts this by 4 for each 'index' to get the required address.
The next line does a translation by passing the contents of this final address to inet_ntoa which converts the ip address in memory to it's textual representation.

Actually, now I look at the code again, the code should technically be this:

p=HostInfo+12 : ` Get address of the top level pointer
p=*p : ` Get the address of the array of pointers
p=p+(index*4) : ` Adjust to get the right pointer
p=*p : ` Get the address of the ip-address
ip=Call Dll(DLLNUM,"inet_ntoa",*p) : ` Convert to text

Luckily windows keeps the ip-addresses stored in a table form

Um, converting to DBC ... very, very difficult. You'd need to use a memblock to store the original data in, access the CopyMemory function from the kernel32.dll to copy the contents of the addresses to another memblock where you could read them. You'd then be able to mimic what my code does.

Alternatively, why not get someone to write a DLL for you (not me I'm afraid ... I'm in the middle of something ATM).
Shadowfax
23
Years of Service
User Offline
Joined: 20th Jan 2003
Location:
Posted: 10th Jul 2003 01:29
Thanks guys,

Appreciate the help ... *especially* the code but it isnt helping

IanM : the code you posted is a help but line 105

"if net message type() = 3 then Result$ = net message string$()"

doesnt compile right .. the compiler only recognizes the commands i have enboldened and not the 'net message string$()' command. Consequently i dont get the 'welcome player' message during runtime.

Have you updated your IDE ? i shouldnt need to do this surely ? I *am* using patch 4.1 .... but was doing the same under patch 3

I will offer thanks in advance ... i know my codings not too bad and this is driving me nuts

"No Gir ... thats BAD !"
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 10th Jul 2003 01:46
I'm using editor patch 1.09+1.09b and patch ... sorry, update4.1 of the compiler

It doesn't highlight correctly in mine either, but it does compile and run correctly.
heartbone
23
Years of Service
User Offline
Joined: 9th Nov 2002
Location:
Posted: 10th Jul 2003 01:53
Right IanM that net message string$() function is correctly documented in the DBCv1.13 docs, however the $ was somehow dropped in the DBPro manual.

Thanks for your explanation of the pointer usage. I'll try to wrap my brain around it.

The more you see, the more you know.
The more you know, the more you see.
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 10th Jul 2003 01:59
Good luck. Just shout if you need some help ... once you've done most of the work of course
Shadowfax
23
Years of Service
User Offline
Joined: 20th Jan 2003
Location:
Posted: 11th Jul 2003 00:42
Done it !

Many thanks folks for all your assistances, the code samples were a great help and after finally going crosseyed i saw it ...

I checked for the message count before getting the message (DOH)

Once again ... many thanks

"No Gir ... thats BAD !"

Login to post a reply

Server time is: 2026-07-18 07:31:21
Your offset time is: 2026-07-18 07:31:21