Sie sind auf Seite 1von 16

UNIVERSIDAD RICARDO PALMA INGENIERIA INFORMATICA

Profesor: Muoz Ibrcena, Pedro Alumno: Malquichagua Canales, Juan Curso: Redes y Comunicacin de Datos II Tema: Proyecto de Laboratorio Sockets

2011
1

SOCKET.3 CODIGO.4 MANUAL..18

Fundamentos Los sockets son un sistema de comunicacin entre procesos de diferentes mquinas de una red. Ms exactamente, un socket es un punto de comunicacin por el cual un proceso puede emitir o recibir informacin. Los sockets fueron desarrollados como un intento de generalizar el concepto de pipe (tubera unidireccional para la comunicacin entre procesos en el entorno Unix) en 4.2BSD bajo contrato por DARPA (Defense Advanced Research Projects Agency). Sin embargo, fueron popularizados por Berckley Software Distribution, de la Universidad Norteamericana de Berkley. Los sockets utilizan una serie de primitivas para establecer el punto de comunicacin, para conectarse a una mquina remota en un determinado puerto que est disponible, para escuchar en l, para leer o escribir y publicar informacin en l, y finalmente para desconectarse. Con todas las primitivas que ofrecen los sockets, se puede crear un sistema de dilogo muy completo. Definicin Un socket es un punto final de un proceso de comunicacin. Es una abstraccin que permite manejar de una forma sencilla la comunicacin entre procesos, aunque estos procesos se encuentren en sistemas distintos, sin necesidad de conocer el funcionamiento de los protocolos de comunicacin subyacentes. Los mecanismos de comunicacin entre procesos pueden tener lugar dentro de la misma mquina o a travs de una red. Generalmente son usados en forma de cliente-servidor, es decir, cuando un cliente y un servidor establecen una conexin, lo hacen a travs de un socket.

Form ClientedePeliculas
private void btnMostrarPeliculasActionPerformed(java.awt.event.ActionEvent evt) { //BOTON MOSTRAR PELICULAS String HOST = txtIP.getText(); final int PUERTO = Integer.parseInt(jTextField2.getText()); try { String archivoCSV; Socket socketCliente = new Socket(HOST, PUERTO); DataOutputStream paraServidor = new DataOutputStream(socketCliente.getOutputStream()); BufferedReader deServidor = new BufferedReader(new InputStreamReader(socketCliente.getInputStream())); paraServidor.writeBytes("\n"); archivoCSV = deServidor.readLine(); jTextArea1.append(archivoCSV + "\n"); archivoCSV = deServidor.readLine(); jTextArea1.append(archivoCSV + "\n"); archivoCSV = deServidor.readLine(); jTextArea1.append(archivoCSV + "\n"); txtRuta.setEnabled(true); btnGuardarEn.setEnabled(true); btnMostrarPeliculas.setEnabled(false); } catch (Exception e) { JOptionPane.showMessageDialog(null, "Error (" + e.getMessage() + ")", "Mensaje", JOptionPane.INFORMATION_MESSAGE); } } private void btnPedirPeliculaActionPerformed(java.awt.event.ActionEvent evt) { //boton Pedir esta pelicula... final int PUERTO = Integer.parseInt(jTextField1.getText()); String IP = txtIP.getText();

try { String frase; String file; String RUTA = txtRuta.getText();

if (txtIP.getText() != null) { Socket socketCliente = new Socket(IP, PUERTO); DataOutputStream paraServidor = new DataOutputStream(socketCliente.getOutputStream());

BufferedReader deServidor = new BufferedReader(new InputStreamReader(socketCliente.getInputStream())); frase = txtPedirPelicula.getText(); paraServidor.writeBytes(frase + '\n'); java.io.InputStream in = socketCliente.getInputStream(); //CREAMOS LA INSTANCIA PARA ESCRIBIR EL ARCHIVO EN DISCO DataInputStream dis = new DataInputStream(socketCliente.getInputStream()); file = dis.readUTF(); java.io.FileOutputStream out = new java.io.FileOutputStream(new java.io.File(RUTA + "\\" + file)); byte[] buf = new byte[1024]; int len; while ((len = in.read(buf)) > 0) { out.write(buf, 0, len); } JOptionPane.showMessageDialog(null, "Encontrar su video en: " + RUTA + "\\" + file, "Transferencia exitosa...", JOptionPane.INFORMATION_MESSAGE); in.close(); out.close(); socketCliente.close(); } else { JOptionPane.showMessageDialog(null, "No ha ingresado el IP", "Error", JOptionPane.WARNING_MESSAGE); } } catch (IOException e) { if (e.getMessage() == null) { JOptionPane.showMessageDialog(null, "No existe la pelcula \"" + txtPedirPelicula.getText() + "\""+e.getMessage(), "Mensaje", JOptionPane.INFORMATION_MESSAGE); } else { JOptionPane.showMessageDialog(null, "Error (" + e.getMessage() + ")", "Mensaje", JOptionPane.INFORMATION_MESSAGE); } } } private void btnGuardarEnActionPerformed(java.awt.event.ActionEvent evt) { // <editor-fold defaultstate="collapsed" desc="orig"> /*GuardarEn a = new GuardarEn(); //Servidor inactivo mientras corra el FileChooser while (a.isActive()) { this.setEnabled(false); } txtRuta.setText(a.ruta); btnPedirPelicula.setEnabled(true); txtPedirPelicula.setEnabled(true);*/ // </editor-fold> int retVal; JFileChooser chooser = new JFileChooser(); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

retVal = chooser.showOpenDialog(this); switch (retVal) { case (JFileChooser.APPROVE_OPTION): txtRuta.setText(chooser.getSelectedFile().getAbsolutePath()); btnPedirPelicula.setEnabled(true); txtPedirPelicula.setEnabled(true); txtPedirPelicula.setText(""); break; case (JFileChooser.CANCEL_OPTION): chooser.setVisible(false); btnPedirPelicula.setEnabled(false); txtPedirPelicula.setEnabled(false); txtRuta.setText("Seleccione el directorio"); break; case (JFileChooser.ERROR_OPTION): txtRuta.setText("Error al seleccionar ruta"); } } private void jTextField2ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: } private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: } private void formWindowOpened(java.awt.event.WindowEvent evt) { javax.swing.JOptionPane.showMessageDialog(this,"Bienvenidos a MalquiVideo","MENSAJE",JOptionPane.INFORMATION_MESSAGE); }

public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { String theme = "ModerateSkin"; JFrame.setDefaultLookAndFeelDecorated(true); SubstanceLookAndFeel.setSkin("org.jvnet.substance.skin."+theme+""); new ClienteDePeliculas().setVisible(true); } }); }

Form ServidorVideos
public class ServidorVideos extends javax.swing.JFrame { /** Creates new form ServidorVideos */ public ServidorVideos() { initComponents(); try{ lblIP.setText(InetAddress.getLocalHost().getHostAddress()); }catch(UnknownHostException e){ lblIP.setText("Error al encontrar la ip local");

} } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() { jPanel1 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); txtRutaVideos = new javax.swing.JTextField(); btnRutaVideos = new javax.swing.JButton(); btnRutaCSV = new javax.swing.JButton(); txtRutaCSV = new javax.swing.JTextField(); jLabel4 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); lblIP = new javax.swing.JLabel(); jLabel5 = new javax.swing.JLabel(); btnDatos = new javax.swing.JButton(); jLabel7 = new javax.swing.JLabel(); jPanel2 = new javax.swing.JPanel(); jScrollPane1 = new javax.swing.JScrollPane(); taResultados = new javax.swing.JTextArea(); jLabel2 = new javax.swing.JLabel(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setTitle("Servidor de Videos"); addWindowListener(new java.awt.event.WindowAdapter() { public void windowOpened(java.awt.event.WindowEvent evt) { formWindowOpened(evt); } }); jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Archivos")); jPanel1.setFont(new java.awt.Font("Comic Sans MS", 0, 11)); // NOI18N jLabel1.setFont(new java.awt.Font("Comic Sans MS", 0, 11)); // NOI18N jLabel1.setText("Ubicacion de los videos"); txtRutaVideos.setText("Seleccione el directorio"); btnRutaVideos.setFont(new java.awt.Font("Comic Sans MS", 0, 11)); // NOI18N btnRutaVideos.setText("Cambiar"); btnRutaVideos.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnRutaVideosActionPerformed(evt); } }); btnRutaCSV.setFont(new java.awt.Font("Comic Sans MS", 0, 11)); // NOI18N btnRutaCSV.setText("Cambiar"); btnRutaCSV.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnRutaCSVActionPerformed(evt); } }); txtRutaCSV.setText("Seleccione el archivo CSV"); jLabel4.setFont(new java.awt.Font("Comic Sans MS", 0, 11)); // NOI18N jLabel4.setText("Ubicacion del archivo *.csv"); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 157, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(txtRutaVideos, javax.swing.GroupLayout.DEFAULT_SIZE, 283, Short.MAX_VALUE) .addComponent(txtRutaCSV, javax.swing.GroupLayout.DEFAULT_SIZE, 283, Short.MAX_VALUE)) .addGap(6, 6, 6) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(btnRutaVideos) .addComponent(btnRutaCSV)))) .addContainerGap()) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(txtRutaVideos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btnRutaVideos)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabel4) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(txtRutaCSV, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btnRutaCSV)) .addContainerGap(12, Short.MAX_VALUE)) ); jLabel3.setFont(new java.awt.Font("Comic Sans MS", 0, 11)); // NOI18N jLabel3.setText("IP Local"); jLabel5.setFont(new java.awt.Font("Comic Sans MS", 0, 11)); // NOI18N jLabel5.setText("Iniciar Transferencia"); btnDatos.setFont(new java.awt.Font("Comic Sans MS", 0, 11)); // NOI18N btnDatos.setText("Iniciar"); btnDatos.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnDatosActionPerformed(evt); } }); jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Resultados")); taResultados.setColumns(20); taResultados.setRows(5); jScrollPane1.setViewportView(taResultados); javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup() .addContainerGap() .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 364, Short.MAX_VALUE) .addContainerGap()) ); jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(lblIP, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 112, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(btnDatos))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 134, Short.MAX_VALUE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE))) .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jLabel3) .addComponent(lblIP, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel7)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel5) .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btnDatos)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 38, Short.MAX_VALUE) .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap()) ); pack(); }// </editor-fold> int puertoBD=6000, puertoVideos=6001; String rutaCSV, rutaVideos; int nEnviosDatos, nEnviosVideos; boolean enviadoCSV, enviandoVideo; boolean servidorVideosActivo; ServerSocket server; private void btnRutaVideosActionPerformed(java.awt.event.ActionEvent evt) {

int retVal; JFileChooser chooser = new JFileChooser(); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); retVal = chooser.showOpenDialog(this); switch (retVal) { case (JFileChooser.APPROVE_OPTION): txtRutaVideos.setText(chooser.getSelectedFile().getAbsolutePath()); break; case (JFileChooser.CANCEL_OPTION): chooser.setVisible(false); txtRutaVideos.setText("Seleccione el directorio"); break; case (JFileChooser.ERROR_OPTION): txtRutaVideos.setText("Error al seleccionar ruta"); } } private void btnRutaCSVActionPerformed(java.awt.event.ActionEvent evt) { int retVal; JFileChooser chooser = new JFileChooser(); //chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); FileNameExtensionFilter filter = new FileNameExtensionFilter("Archivos CSV", "csv"); chooser.setFileFilter(filter); retVal = chooser.showOpenDialog(this); switch (retVal) { case (JFileChooser.APPROVE_OPTION): txtRutaCSV.setText(chooser.getSelectedFile().getAbsolutePath()); break; case (JFileChooser.CANCEL_OPTION): chooser.setVisible(false); txtRutaCSV.setText("Seleccione el archivo CSV"); break; case (JFileChooser.ERROR_OPTION): txtRutaCSV.setText("Error al seleccionar archivo"); } } private void btnDatosActionPerformed(java.awt.event.ActionEvent evt) { boolean enviado = false; try { String fraseCliente; String ruta = txtRutaCSV.getText(); CsvReader reader = new CsvReader(ruta); while (!enviado) { ServerSocket socketRecepcion = new ServerSocket(puertoBD); Socket socketConexion = socketRecepcion.accept(); BufferedReader deCliente = new BufferedReader(new InputStreamReader(socketConexion.getInputStream())); DataOutputStream paraCliente = new DataOutputStream(socketConexion.getOutputStream()); fraseCliente = deCliente.readLine(); if (fraseCliente.isEmpty()) { while (reader.readRecord()) { String nomArchivo = reader.get(0); String nomPelicula = reader.get(1); String protagonista = reader.get(2); paraCliente.writeBytes(nomArchivo+" - "+nomPelicula+" - "+protagonista+"\n"); } socketRecepcion.close(); socketConexion.close(); enviado = true; //btnDatos.setText("Detener");

10

taResultados.append("Base de Datos enviada\n"); } } } catch (IOException e) { JOptionPane.showMessageDialog(null, "Error (" + e.getMessage() + ")", "Mensaje", JOptionPane.INFORMATION_MESSAGE); //btnDatos.setText("Detener"); } try { server = new ServerSocket(puertoVideos); Socket client = null; String NombrePelicula; while (!servidorVideosActivo) { try { //ESPERA A QUE LLEGUE UN CLIENTE client = server.accept(); taResultados.append("Conexion establecida\n"); } catch (java.io.IOException e) { taResultados.append("No se pudo establecer conexion con el cliente (" + e.getMessage() + ")\n"); JOptionPane.showMessageDialog(null, "No se pudo establecer conexion con el cliente (" + e.getMessage() + ")", "Programa de Descarga", JOptionPane.INFORMATION_MESSAGE); } try { BufferedReader deCliente = new BufferedReader(new InputStreamReader(client.getInputStream())); DataOutputStream paraCliente = new DataOutputStream(client.getOutputStream()); NombrePelicula = deCliente.readLine(); String rutaCSV = txtRutaCSV.getText(); FileInputStream FEntrada = new FileInputStream(rutaCSV); BufferedReader BufEntrada = new BufferedReader(new InputStreamReader(FEntrada)); try { StringTokenizer Parser; String Linea = BufEntrada.readLine(); boolean encontrado = false; while ((Linea != null) && (!encontrado)) { Parser = new StringTokenizer(Linea, ",", false); try { String NombreDescarga = Parser.nextToken(); String Nombre = Parser.nextToken(); if (Nombre.equalsIgnoreCase(NombrePelicula)) { java.io.FileInputStream in = null; java.io.FileOutputStream pt = null; try { String rutaVideos = txtRutaVideos.getText() + "\\"; pt = (java.io.FileOutputStream) client.getOutputStream(); in = new java.io.FileInputStream(new java.io.File(rutaVideos + NombreDescarga)); DataOutputStream dos = new DataOutputStream(client.getOutputStream()); dos.writeUTF(NombreDescarga); } catch (Exception e) { JOptionPane.showMessageDialog(null, "No se pudo crear la conexion (" + e.getMessage() + ")", "Mensaje", JOptionPane.INFORMATION_MESSAGE); server.close(); client.close(); } try { client.sendUrgentData(100); byte[] buf = new byte[1024];

11

int len; while ((len = in.read(buf)) > 0) { pt.write(buf, 0, len); } pt.close(); in.close(); client.close(); servidorVideosActivo = true; } catch (Exception e) { JOptionPane.showMessageDialog(null, "Error al enviar mensaje (" + e.getMessage() + ")", "Mensajer", JOptionPane.INFORMATION_MESSAGE); } taResultados.append("Video enviado: " + NombreDescarga + "\n"); server.close(); encontrado = true; } } catch (NoSuchElementException e) { JOptionPane.showMessageDialog(null, "Error (" + e.getMessage() + ")", "Mensaje", JOptionPane.INFORMATION_MESSAGE); } Linea = BufEntrada.readLine(); } if (!encontrado) { taResultados.append("No se encontro el video solicitado\n"); //enviado = true; btnDatos.setText("Detener"); BufEntrada.close(); FEntrada.close(); server.close(); client.close(); } } catch (IOException e) { JOptionPane.showMessageDialog(null, "Error (" + e.getMessage() + ")", "Mensaje", JOptionPane.INFORMATION_MESSAGE); System.exit(1); BufEntrada.close(); FEntrada.close(); paraCliente.writeBytes(NombrePelicula + "no encontrado"); } catch (Exception e) { JOptionPane.showMessageDialog(null, "Error (" + e.getMessage() + ")", "Mensaje", JOptionPane.INFORMATION_MESSAGE); } } catch (Exception e) { JOptionPane.showMessageDialog(null, "Error (" + e.getMessage() + ")", "Mensaje", JOptionPane.INFORMATION_MESSAGE); System.exit(1); } } } catch (IOException e) { JOptionPane.showMessageDialog(null, "Error (" + e.getMessage() + ")", "Mensaje", JOptionPane.INFORMATION_MESSAGE); } } private void formWindowOpened(java.awt.event.WindowEvent evt) { javax.swing.JOptionPane.showMessageDialog(this,"Bienvenidos a LoganVideo","MENSAJE",JOptionPane.INFORMATION_MESSAGE); } /** * @param args the command line arguments

// TODO add your handling code here:

12

*/ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { String theme = "ModerateSkin"; JFrame.setDefaultLookAndFeelDecorated(true); SubstanceLookAndFeel.setSkin("org.jvnet.substance.skin."+theme+""); new ServidorVideos().setVisible(true); } }); }

1.- Entramos a Netbeans, abrimos nuestro proyecto y ejecutamos primero el form Servidor de Videos. Luego el form Cliente.

13

2.- En el form Servidor de Videos presionamos el botn cambiar y buscamos la ubicacin de los videos. De la misma manera hacemos para la base de datos y presionamos el botn iniciar.

14

3.- En el form Servidor de Videos presionamos el botn cambiar y buscamos la ubicacin de los videos. De la misma manera hacemos para la base de datos y presionamos el botn iniciar.

4.- En el form cliente ponemos la ubicacin en donde se enviara el video y el nombre del video.

15

5.- En el form cliente ponemos la ubicacin en donde se enviara el video y el nombre del video. Entonces presionamos el botn nombre del video y nos aparecer el siguiente mensaje.

16

Das könnte Ihnen auch gefallen