Groups | Blog | Home
all groups > visual c > august 2005 >

visual c : SocketFlags.None does not work


Hasan O
8/30/2005 12:00:00 AM
Hi ,
maybe it is not the right place to ask .

Hi , i have problem about sending data over socket . It waits for another
socket.send

// str = Encoding.ASCII.GetBytes("hello");

socket.Send(str,0,str.Length,SocketFlags.None);

socket.Receive(strincome,0,socket.Available,SocketFlags.None); // return
"hello to you "

// str =Encoding.ASCII.GetBytes( "how_are_you ");

socket.Send(str,0,str.Length,SocketFlags.None);

socket.Receive(strincome,0,socket.Available,SocketFlags.None);// return
"fine"



it sends like this "hellohow_are_you" , but it is wrong , how can i solve it
?

William DePalo [MVP VC++]
8/30/2005 12:12:22 PM
[quoted text, click to view]

You are not sending the null byte that terminates the string "hello". If all
your transmissions are strings you will need to add 1 to the length of
everything that you send. Of course, then the receiver has to make the same
assumption either create and array of strings or separate one from the next
by some delimiter.

Regards,
Will

AddThis Social Bookmark Button