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
Page 2 of 2 1 2
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 Offline OP
Senior Member
NeoNeper  Offline 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 Offline OP
Senior Member
NeoNeper  Offline 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: NeoNeper] #403389
06/19/12 09:25
06/19/12 09:25
Joined: Apr 2008
Posts: 585
Austria
Petra Offline
Support
Petra  Offline
Support

Joined: Apr 2008
Posts: 585
Austria
If know C as you claim, then why cant you program in lite-C? Its almost the same as C.

I looked at your code and the first one was almost right except for some bugs that people showed you. But instead of fixing them you made more versions that become even more wrong. Your last version is total nonsense, now you're sending not even data but a pointer. Think logically, how can the other PC know that your STRING* pointed to some name like "Mike"? You must send the string content and not its pointer.

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 Offline OP
Senior Member
NeoNeper  Offline OP
Senior Member

Joined: Nov 2007
Posts: 318
Brasil, Paraná
Tank you Petra.
You saw correctly the last example that I sent?


Quote:

Hy TechMuc. Tanks for response.

//The server will receive a data packet

Code:
//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

Code:
...
	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: NeoNeper] #403399
06/19/12 13:26
06/19/12 13:26
Joined: Jul 2008
Posts: 894
T
TechMuc Offline
User
TechMuc  Offline
User
T

Joined: Jul 2008
Posts: 894
Again: an char array is the correct way of sending "strings" over the network. The above example (with the STRING* pointer) will send the correct pointer to the different computer. The problem is, that you're only sending the pointer, but NOT the string object itself, which is not possible either ways.

So: Just use you're first approach with char[20] and use strcpy instead of str_cpy.

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 Offline OP
Senior Member
NeoNeper  Offline 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:
Code:
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:
Code:
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.
_______________________________________________________
Re: How to send and receive data (char *) with send_data? [Re: NeoNeper] #403480
06/21/12 06:47
06/21/12 06:47
Joined: Jul 2008
Posts: 894
T
TechMuc Offline
User
TechMuc  Offline
User
T

Joined: Jul 2008
Posts: 894
just as a last "annotation": generally you can use ALL exported functions defined in any DLL - without any change you can use any windows api function defined in the file windows.h.

Page 2 of 2 1 2

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