private void Hablar(Object pos) { Conversacion actual = null; try { actual = Procesos[(int)pos]; while (!actual.cerrado) { int tam = actual.puerto.ReceiveBufferSize; byte[] buff = new byte[tam]; actual.puerto.Receive(buff, tam, SocketFlags.None); String datos = ProcesarBytes.EncodeBytes(buff); //Evento datos recibidos OnDatosRecibidos(datos, (int)pos); } } catch (Exception ex) { } finally { OnConexionTerminada(actual.puerto.RemoteEndPoint.ToString()); actual.puerto.Close(); actual.Cerrar(); //Conexion Terminada } }
private void Escuchar() { try { while (varcliente.Connected) { int tam = varcliente.ReceiveBufferSize; byte[] bytedatos = new byte[tam]; varcliente.Client.Receive(bytedatos); String datos = ProcesarBytes.EncodeBytes(bytedatos); //On datos recibidos OnDatosRecibidos(datos); } } catch (Exception ex) { } finally { //Conexion Terminada OnConexionTerminada(); } }
public void EnviarDatos(int pos, String datos) { byte[] bytedatos = ProcesarBytes.DecodeByte(datos); Procesos[pos].puerto.Send(bytedatos, datos.Length, SocketFlags.None); }
public void EnviarDatos(String datos) { byte[] datosbyte = ProcesarBytes.DecodeByte(datos); srw.Write(datosbyte, 0, datosbyte.Length); }