Gamestudio Links
Zorro Links
Newest Posts
zorro license, IB connection
by miwok. 12/06/23 16:32
Newbie Questions
by fairtrader. 12/06/23 11:29
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
6 registered members (miwok, AndrewAMD, TipmyPip, 3run, Quad, 1 invisible), 645 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
How to send and receive data (char *) with send_data? #403003
06/13/12 13:05
06/13/12 13:05
Joined: Nov 2007
Posts: 318
Brasil, Paraná
NeoNeper Offline OP
Senior Member
NeoNeper  Offline OP
Senior Member

Joined: Nov 2007
Posts: 318
Brasil, Paraná
I'm not having success in the receipt of characters (char*), using the function ("send_data");

Below is an example of how I'm trying:

On Server:
Code:
typedef struct MYDATA {
  int id;
  char name[20];
} MYDATA;


MYDATA* mydata = { id = 0; name = ""; }	

function server_event(STRING* name, var idd)
{

	if (event_type == EVENT_JOIN)
	{
	//send_data for all Clients
        mydata.name="Mike";
        mydata.id=10;
	send_data_to(NULL,mydata,sizeof(MYDATA));
	}
}



In the example described above, I Sending a data packet to all Clients
The data packet sends a whole number ("ID") and a sequence of characters ("name")
>Now I'll describe how I'm working on the "Client" to receive this data packet

On Clients:

Code:
typedef struct MYDATA {
  int id;
  char name[20];
} MYDATA;


STRING* mystring = "";
TEXT* tMessage = { string(mystring); flags |= SHOW; layer = 1;  pos_x = 10;  pos_y = 50;  font = "arial#16b"; }

MYDATA* mydata = { id = 0; name = ""; }	

function client_event(void* buffer)
{

 if(event_type == EVENT_DATA){
 	
 	
 	memcpy(mydata,buffer,sizeof(MYDATA));
 	str_cat((tMessage.pstring)[0],str_for_num(NULL,mydata.id));
 	str_cat((tMessage.pstring)[0]," / ");
 	str_cat((tMessage.pstring)[0],mydata.name);
 	
 	}
}




There are the practical examples that show how I am sending a data packet from the server to the client, and also how I'm getting this information into Client.

In testing what happens is:
The value (int id) is being sent and received successfully
But I'm not having the same success with the data (char* name)
When I go to print on screen the result of the data packet received, the value (int id) is correct, but the value (char * name) is not correct. It comes empty or comes with a lot of unknown characters .



Can anyone help me?


Last edited by NeoNeper; 06/13/12 13:18.

Please! Use easy words to be translated. because my English is not very good! Grateful.
_______________________________________________________
Re: How to send and receive data (char *) with send_data? [Re: NeoNeper] #403004
06/13/12 13:13
06/13/12 13:13
Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
Espér Offline
Expert
Espér  Offline
Expert

Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
perhaps you've written 'nome' instead of 'name' ?


Selling my Acknex Engine Editions (A7 Com & A8 Pro):
>> click here if you are interested <<
Re: How to send and receive data (char *) with send_data? [Re: Espér] #403005
06/13/12 13:17
06/13/12 13:17
Joined: Nov 2007
Posts: 318
Brasil, Paraná
NeoNeper Offline OP
Senior Member
NeoNeper  Offline OP
Senior Member

Joined: Nov 2007
Posts: 318
Brasil, Paraná
Ohh No No. Sory.
It was a typo here!
In the script are all instantiated as "name".

But Thanks for your attention (^.^).
I fix the Previous Post!

PS: It is worth remembering that I'm using an unprotect connection. (*)
Sample:
session_open("*test")
And
session_connect("*test","localhost");


Last edited by NeoNeper; 06/13/12 13:22.

Please! Use easy words to be translated. because my English is not very good! Grateful.
_______________________________________________________

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1