Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 208
  • Last Modified:

Sending String

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
Students
Asked:
Students
1 Solution
 
oferhCommented:
txt is pointingto the class itself not to the data try:
sockClient.Send(txt.GetBuffer(),len);
0
 
sarda_rameshCommented:
oferh is rite

0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now