Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

zahid

distiguish an object ,, that is send by socket

This topic is 5345 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi, i have created an array UCHAR * m_array; m_array = new UNCHAR [size] i saved data in it ,, that PCM data (pulse code modulation) now i want to send this (array) throught socket. but i want to place some TAG before this that helps me on server side that i m recivng an array CString str = " <>"; E.G .. ? = str + m_array( i.e object of array ) in which(?) i store it. m_array is not a string data; how can i addup this type of tag that helps me on server side to distiguish this that it is an array object ,, not ohter data... if its successfull to add up a tag then using CSocket->send ( ...... , .. , ...); it can be send Plz reply me about adding a tag thanx

Share this post


Link to post
Share on other sites
Advertisement

char buf[256]; //just some number

strcpy(buf, "<TAG>");
strcat(buf, m_array);

// now send buffer on its happy way


that is assumming m_array is NULL terminated

"A soldier is a part of the 1% of the population that keeps the other 99% free" - Lt. Colonel Todd, 1/38th Infantry, Ft. Benning, GA

[edited by - ncsu121978 on February 6, 2004 10:22:04 AM]

[edited by - ncsu121978 on February 6, 2004 10:22:41 AM]

Share this post


Link to post
Share on other sites


but m_array is a sound data ... how it is a NULL terminated..
its not a string
strcat etc r string functions

will thay help to concatinate
+ m_array (sound data.)

thanx

Share this post


Link to post
Share on other sites

char buf[big_size];
strcpy(buf, "<TAG>");
memcpy(m_array, (buf+strlen(buf)), size);
// send buffer on its happy way




"A soldier is a part of the 1% of the population that keeps the other 99% free" - Lt. Colonel Todd, 1/38th Infantry, Ft. Benning, GA

Share this post


Link to post
Share on other sites
ok...

but now how can i seperate them

i means ..my tag and m_array .. when i will revieve them on other side ( on specific Client Socket).

assume i get them on other side and want to seperate sound data (m_array) from my tag.

where i will play my m_array

thanx

Share this post


Link to post
Share on other sites
Since you are writing the code for server and client
you should know how big your tag is.
if you go really simple and tag your data with an
int
then on the server side you recieve to a buffer, and
so your data is simply at
(buffer+sizeof(int))
but the same effect works for any sized tag

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!