sde
Centurion
i'm trying to get a server/client app to work. i want my client app to read anything the server is sending it.
i've put the Stream.Read method inside a timer, but it just hangs when i run it. the exception doesn't even trigger. am i going about this wrong?
on the server side, i'm using this to send
i've put the Stream.Read method inside a timer, but it just hangs when i run it. the exception doesn't even trigger. am i going about this wrong?
Code:
// initialization
TcpClient tcpclnt = new TcpClient();
tcpclnt.Connect("10.10.10.10',8001);
Stream stm = tcpclnt.GetStream();
.....
this.timer1.Interval = 1000;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
this.timer1.Start();
...
private void timer1_Tick(object sender, System.EventArgs e)
{
try
{
byte[] bb = new byte[100];
int k = stm.Read(bb,0,100);
for ( int i=0 ; i<k ; i++ )
txtBox.Text += (Convert.ToChar(bb[i]));
}
catch(Exception p)
{
MessageBox.Show(p.ToString());
}
}
on the server side, i'm using this to send
Code:
Socket s = new Socket();
ASCIIEncoding asen = new ASCIIEncoding();
s.Send(asen.GetBytes("string"));