Click here to Skip to main content
15,891,976 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
I created one structure to hold the folder properties.
C#
typedef struct
{
    string FolderName;
    int Foldersize;
    int FolderFiles;
}DeskFold;


Then I used a structure vector to collect the folder properties present in desktop.
vector<DeskFold> MyVect;

Now the vector has folder name, number of files inside it and folder size.

I want to send these data in vector to server through TCP/IP socket connection.
But the send() function can send only the char *.

Now what I want to do to send those data in vector?..

Please help me...
Posted

Sending the vector a once is not possible using send command.

You can came a structure which contains the vector index and the data.
Use the send() function for all vector elements.

while using send type cast the structure pointer.

On the receiving side constuct the vector accoringly.
 
Share this answer
 
Comments
IT-NEWBIE 27-Jul-11 7:54am    
With your guidance I did like this:
/*delcaration*/
typedef struct
{
vector<deskfold> StructVect;
}MyStruct;

and in main() function,
/*
MyStruct *Obj = new MyStruct();
Obj->StructVect = MyVect;
*/

Is this the right way?

Am I moving as per your words?
Vectors and strings are dynamic. You cannot "send them" by hardcopying the memory the instance resides.
To send them you have to serialize in sending and deserialize in reading.
(Try Google for "C++ data serialization", to get information).

That's not by itself an easy concept, but before lost yourself in an infinite wood of "let's try how to cat this s*it into a char*", STOP a WHILE.

Basing on your previous comments, it not conceivable that someone like you, with still problem in understanding how the basic data-structures like vectors and strings work, pretend to work with networked machines and socket communication.

You've first to understand how dynamic data structure work (note: data structure is not a synonymous of struct) then understand things like "serialization" and "marshaling". And eventually "parsing".

You can also succeed with comfortable shortcuts and a lot of coy&paste, but writing a code you don't understand may fool someone, but you cannot fool anyone for all of your life!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900