09/09/11 14:06
DexterELEL
Ragazzi nel creare una chat client server sono arrivato alla parte della chat.. ho creato il Send e Receive che sono rispettivamente
Send:
Receive:
Ok, ma il messaggio sul client non appare sapreste dirmi dove ho sbagliato?
Send:
public void InviaATutti(string MESSAGGIO) { foreach (Socket s in Sockets) { s.Send(ASCIIEncoding.ASCII.GetBytes(MESSAGGIO)); } }
Receive:
public void RiceviMessaggi() { TcpClient Connector = new TcpClient(); int port = int.Parse(textBox2.Text); IPAddress ipAdd = IPAddress.Parse(textBox1.Text); EndPoint ep = new IPEndPoint(ipAdd, port); Socket s = new Socket(ep.AddressFamily, SocketType.Stream, ProtocolType.IP); s.Connect(ep); if (Connector.Available > 0) { byte[] msg = new byte[Connector.Available]; s.Receive(msg); string testo = ASCIIEncoding.ASCII.GetString(msg); listBox1.Items.Add(testo); s.Close(); } else { s.Close(); } }
Ok, ma il messaggio sul client non appare sapreste dirmi dove ho sbagliato?
aaa