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.

Dark GDK / MultiSync - sending char values error

Author
Message
CheatCat
17
Years of Service
User Offline
Joined: 7th Mar 2007
Location: Sweden
Posted: 17th Jul 2008 21:02
Well, I try to send some text from the host to client, but I only get this error:


Here is the host code:


And the client:
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 17th Jul 2008 21:47 Edited at: 17th Jul 2008 21:48
This is your problem



You haven't allocated any space to store the returned string data.

CheatCat
17
Years of Service
User Offline
Joined: 7th Mar 2007
Location: Sweden
Posted: 19th Jul 2008 19:51
And my dumb question is: How I allocate space to store the string?
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 19th Jul 2008 21:18 Edited at: 19th Jul 2008 21:20
See this on dynamic memory allocation. What you need to do is use the new operator to allocate memory, and store the pointer it returns. For example:



Always make sure the buffer is big enough to store the data you want to put in it, and remember to account for the fact that you need an extra byte to store the zero character at the end of a string.

When you no longer need the buffer, you can free it using delete. Note that you need to specify brackets before the variable name if you allocated multiple items (which in this case you are):



CheatCat
17
Years of Service
User Offline
Joined: 7th Mar 2007
Location: Sweden
Posted: 20th Jul 2008 20:33
But how I do if I whant to store more than one value in the playername array?

I have tried with this:


And I get this error:
CheatCat
17
Years of Service
User Offline
Joined: 7th Mar 2007
Location: Sweden
Posted: 21st Jul 2008 20:43
I get it! Almost... :S

Host:


Client:


But I get an popup with this error:
"Message full, cannot write."

Should I empty the char array, and how?
haYnguy
16
Years of Service
User Offline
Joined: 5th Jun 2008
Location: on my island
Posted: 27th Jul 2008 07:00
No, you need to do NetSend(0) after NetSendAll(); to clear out the message buffer.

-- from my island, aloha wau 'ia 'oe --

Login to post a reply

Server time is: 2024-11-20 17:42:51
Your offset time is: 2024-11-20 17:42:51