Servidor(1) - / Configurar un servidor que reciba una...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
// una cadena al cliente y cierre la conexi n. import java.io.*; import java.net.*; import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Servidor extends JFrame { private JTextField campoIntroducir; private JTextArea areaPantalla; private ObjectOutputStream salida; private ObjectInputStream entrada; private ServerSocket servidor; private Socket conexion; private int contador = 1; // configurar GUI public Servidor() { super( "Servidor" ); Container contenedor = getContentPane(); // crear campoIntroducir y registrar componente de escucha campoIntroducir = new JTextField(); campoIntroducir.setEditable( false ); campoIntroducir.addActionListener( new ActionListener() { // enviar mensaje al cliente public void actionPerformed( ActionEvent evento ) { enviarDatos( evento.getActionCommand() ); campoIntroducir.setText( "" ); } } ); contenedor.add( campoIntroducir, BorderLayout.NORTH ); // crear areaPantalla areaPantalla = new JTextArea(); contenedor.add( new JScrollPane( areaPantalla ), BorderLayout.CENTER ); setSize( 300, 150 ); setVisible( true ); } // fin del constructor de Servidor // configurar y ejecutar el servidor public void ejecutarServidor() { // configurar servidor para que reciba conexiones; procesar las conexiones try { // Paso 1: crear un objeto ServerSocket. servidor = new ServerSocket( 12345, 100 );
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/04/2011 for the course ECOM 101 taught by Professor Juan during the Spring '11 term at Université de Caen Basse Normandie, Caen University.

Page1 / 4

Servidor(1) - / Configurar un servidor que reciba una...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online