?
Solved

Sending String

Posted on 2003-03-10
2
Medium Priority
?
206 Views
Last Modified: 2010-04-01
I'm having problem with sending text/CString over through CSocket. Here are my codes

Server-----
int recelength;
sockRece.Receive(&recelength,4);
char* buff = new char[recelength];
sockRece.Receive(buff,recelength);

for(int i=0; i<recelength; i++)
{
printf("%c",buff[i]);
}

Client-----

CString txt = "There is no ppples";
int len=txt.GetLength();
sockClient.Send(&len,4);
sockClient.Send(txt,len);

-----
Output will be (T h e r e       is)*without the brackets..

Any help or advice is appreciated.
Please help some website about sending text.
0
Comment
Question by:Students
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 1

Accepted Solution

by:
oferh earned 90 total points
ID: 8102203
txt is pointingto the class itself not to the data try:
sockClient.Send(txt.GetBuffer(),len);
0
 
LVL 1

Expert Comment

by:sarda_ramesh
ID: 8102947
oferh is rite

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question