|
|
Re: How to send and receive data (char *) with send_data?
[Re: jcl]
#403337
06/18/12 13:14
06/18/12 13:14
|
Joined: Nov 2007
Posts: 318 Brasil, Paraná
NeoNeper
OP
Senior Member
|
OP
Senior Member
Joined: Nov 2007
Posts: 318
Brasil, Paraná
|
EDIT:
Last edited by NeoNeper; 06/18/12 13:21.
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]
#403339
06/18/12 13:49
06/18/12 13:49
|
Joined: Nov 2007
Posts: 318 Brasil, Paraná
NeoNeper
OP
Senior Member
|
OP
Senior Member
Joined: Nov 2007
Posts: 318
Brasil, Paraná
|
I know very well programing in C / C + +. What I do not know very well is programing in Litec! What should I do? Create a C + + DLL for receiving a structure of the C-LITE and returns values ;such that the Litec can understand! is it?
PS: By the time I'm using 100% Litec. In no time I used (C # / C + +).
I'm talking about (Lite.C) and you are in (C # / C + +). So we're disagreeing. And you're not helping me. but deichando me with more questions!
In my last post, I showed an example that has no misstatement. I changed the (char *) by (STRING *) and I did a test before sending by (send_data).
I managed to create the appointment for Struct.
Could include the values (ID and NAME) sucefull. And also I can print these values;, using the str_cpy and _str_cat Litec.
There was no problem.
But when I send this data package with send_data, the value (STRING *) is not being sent correctly, or not being properly recoperado.
When I print the result on the screen, the value (int id) corresponds to what I sent, but the value (STRING * name) does not match sent.
Please check my LAST POST that contains this example. Try yourself, send a data packet containing (* STRING) to a Section does not Protected.
Then. Only then, answer me if can succeed. I strongly believe that there is a BUG in relation to send_data.
As I said earlier, I am USING the # LITEC. I made a file (server.c) and another (cliente.c) And I'm trying to communicate using non-protected section.
Last edited by NeoNeper; 06/18/12 16:11.
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: Petra]
#403398
06/19/12 12:45
06/19/12 12:45
|
Joined: Nov 2007
Posts: 318 Brasil, Paraná
NeoNeper
OP
Senior Member
|
OP
Senior Member
Joined: Nov 2007
Posts: 318
Brasil, Paraná
|
Tank you Petra. You saw correctly the last example that I sent? Hy TechMuc. Tanks for response. //The server will receive a data packet
//define macro new
#define new(type) malloc(sizeof(type##))
typedef struct MYDATA {
int id;
STRING* name;
} MYDATA;
function server_event(void* buffer)
{
if (event_type == EVENT_DATA)
{
//Start Struct
MYDATA* mydata = new(MYDATA);
mydata.id=0;
mydata.name=str_create("");
//Copy struct
memcpy(mydata,buffer,sizeof(MYDATA));
str_cpy((server_txt.pstring) [0],str_for_num(NULL,mydata.id)); //Sucefull
str_cat((server_txt.pstring)[0],"\n");
str_cat((server_txt.pstring)[0],mydata.name); //No Sucefull
}
}
Note that I modified the script, replacing the "char name []" for "STRING * name;" This is a functional script. However, when using the send_data to send this packet, the data in (STRING *) are lost. When I capture the packets sent, usually I get any numeric value. but the values ​​of writing, even if using "STRING *" are not correctly sender, or received! Function that sends data packets into client
...
MYDATA* mydata = new(MYDATA);
mydata.id = 100;
mydata.name= str_create("");
str_cpy(mydata.name,"julio");
send_data_to(NULL,mydata,sizeof(MYDATA));
...
Note how I'm doing to send the packet! This is a valid function. But this data in STRING * is not being sent correctly! Or, these data are being sent correctly, but I am not using a proper way to capture this data in "STRING *" And there is also the possibility that we are seeing a bug enguine! Note that I did not send a empty pointer to the STRING * name SEE: mydata.name = str_create(""); str_cpy(mydata.name,"julio"); send_data_to(NULL,mydata,sizeof(MYDATA)); I've also tried this: str_cpy(mydata.name,"julio"); send_data_to(NULL,mydata,sizeof(MYDATA)); This is not valid? I thought I could also send String And once again thank you for your attention
Last edited by NeoNeper; 06/19/12 12:57.
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: TechMuc]
#403408
06/19/12 16:16
06/19/12 16:16
|
Joined: Nov 2007
Posts: 318 Brasil, Paraná
NeoNeper
OP
Senior Member
|
OP
Senior Member
Joined: Nov 2007
Posts: 318
Brasil, Paraná
|
AAffff. Excuse me for my stubbornness.!!! I had no idea that I could use scripts (#C) directly in engine. You are absolutely right! Using (strcpy) instead of (str_cpy) works! ON SERVER:
typedef struct MYDATA {
int id;
char _name[10];
} MYDATA;
function receive(void* receive){
MYDATA* mydata = new(MYDATA);
memcpy(mydata,receive,sizeof(MYDATA));
STRING* temp = "";
strcpy(temp,mydata._name[0]);//strcpy #C script
str_cat((server_txt.pstring)[0],temp);//OutPut ("Mike");
}
ON CLIENT - Function for SEND Data:
typedef struct MYDATA {
int id;
char _name[10];
} MYDATA;
function senddata()
{
MYDATA* mydata= new(MYDATA);
mydata.id=100;
strcpy(mydata._name, "Mike" ); //strcpy #C script
send_data_to(NULL,mydata,sizeof(MYDATA));
}
ITS WORRRRRRRRRKK... (^.^) I was thinking that the char array, was used to index multiple values ​​("strings") distinct. Sample: char name[2] name[0] = "fist name"; name[1] = "second name"; ... Since in fact the character array is used to index the char's of the "string" Thank you all, and also apologize for any inconvenience.
Last edited by NeoNeper; 06/19/12 16:18.
Please! Use easy words to be translated. because my English is not very good! Grateful. _______________________________________________________
|
|
|
|