ok i have a project, in my poject i have a client and a server the client send data to server over tcp/ip on a socket
My data arrives as a bytes and then they are converted to chars..
Here`s the code a little bit
CSocketPacket theSockId = (CSocketPacket)asyn.AsyncState; //end receive... int iRx = 0;iRx = theSockId.thisSocket.EndReceive(asyn);
char[] chars = new char[iRx + 1];// decodes the bytes
System.Text.Decoder d = System.Text.Encoding.UTF8.GetDecoder();
int charLen = d.GetChars(theSockId.dataBuffer, 0, iRx, chars, 0);
System.String szData = new System.String(chars);
command=command+szData.
MessageBox.Show(szData);
WaitForData(m_socWorker);
comand is a string type , my problem is here:
command=command+szData. // the command foes not take new value
for example:
first string command="";
and szData="b";
command=command+szData. // now command is ="b";
szData="c";
command=command+szData. // now command it supposed to be "bc"
well it doesnt it still b;
What am i doing wrong

help with string!!!
JonM
CalBob
man szData works fine, when he supposed to be "b" its "b" when its supposed to be "c" is "c"
the realy problem is with command
commnad =command+szData;
he only take szData value once, and then he doesnt take the new value of szData
mrferg
//this is in button 1 click
try
{
//create the listening socket...m_socListener =
new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); IPEndPoint ipLocal = new IPEndPoint(IPAddress.Any, 8221); //bind to local IP Address...m_socListener.Bind(ipLocal);
//start listening...m_socListener.Listen(19);
// create the call back for any client connections...m_socListener.BeginAccept(
new AsyncCallback(OnClientConnect), null);}
catch (SocketException se){
MessageBox.Show(se.Message);} // end f button 1 click
public void OnClientConnect(IAsyncResult asyn)
{
try
{
m_socWorker = m_socListener.EndAccept(asyn);
WaitForData(m_socWorker);
}
catch (ObjectDisposedException){
System.Diagnostics.
Debugger.Log(0, "1", "\n OnClientConnection: Socket has been closed\n");}
catch (SocketException se){
MessageBox.Show(se.Message);}
}
public class CSocketPacket{
public System.Net.Sockets.Socket thisSocket; public byte[] dataBuffer = new byte[1];}
public void WaitForData(System.Net.Sockets.Socket soc){
try{
if (pfnWorkerCallBack == null){
pfnWorkerCallBack =
new AsyncCallback(OnDataReceived);}
CSocketPacket theSocPkt = new CSocketPacket();theSocPkt.thisSocket = soc;
// now start to listen for any data...soc.BeginReceive(theSocPkt.dataBuffer, 0, theSocPkt.dataBuffer.Length,
SocketFlags.None, pfnWorkerCallBack, theSocPkt);}
catch (SocketException se){
MessageBox.Show(se.Message);}
}
string b = ""; public void OnDataReceived(IAsyncResult asyn){
try{
CSocketPacket theSockId = (CSocketPacket)asyn.AsyncState; //end receive... int iRx = 0;iRx = theSockId.thisSocket.EndReceive(asyn);
char[] chars = new char[iRx + 1];System.Text.
Decoder d = System.Text.Encoding.UTF8.GetDecoder(); int charLen = d.GetChars(theSockId.dataBuffer, 0, iRx, chars, 0);System.
String szData = new System.String(chars);b = b + szData.ToString();
WaitForData(m_socWorker);
}
catch (ObjectDisposedException){
System.Diagnostics.
Debugger.Log(0, "1", "\nOnDataReceived: Socket has been closed\n");}
catch (SocketException se){
MessageBox.Show(se.Message);}
}
this is the server side o a network program, so as u could see the problem is in OnDataRecevice
crystalreports
VOEagain