Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_java_server thread: Sockets in applets ?


Message #1 by "HDLP" <lab.automacao@e...> on Thu, 15 Jun 2000 1:46:48
Hi Henrique 

In case of applet u can only open a socket with a
server ,on which ur applet resides...Second way is to
use signed applet 



Imran

--- aseem <aseem@o...> wrote:
> Socket definetely works in the applet on the browser
> as the chat application using the Socket , uses the
> same technique
> 
> Aseem
> 
> HDLP wrote:
> 
> > Hi
> >    I want to make a socket conection inside an
> applet, but it seems don´t
> > work if the applet is on a browser. Why ?
> >
> > Can someone help me ?
> >
> >  the problem is that it can´t open the conection.
> >
> > here is my code:
> >
> > import java.awt.*;
> > import java.applet.*;
> > import java.awt.event.*;
> > import java.io.*;
> > import java.net.*;
> > import java.util.*;
> >
> > public class Teste extends Applet{
> >
> >         TextField baseText;
> >         String ButtonPushed = null;
> >         String erro = null;
> >         Button Butao = new Button ("O.K.");
> //definição do butao
> >
> >         public void init()
> >         {
> >
> >                 baseText = new TextField("",4);
> >
> >                 Butao.addActionListener(new
> ButaoListener()); //adiciono a classe dos
> > eventos
> >
> >                 add(baseText); //adiciono a caixa
> de texto
> >                 add(Butao); //adiciono o butao
> >
> >                 add(new Label("Feito por :
> HDLP"));
> >         }
> >
> >         class ButaoListener implements
> ActionListener
> >         {
> >                 public void actionPerformed
> (ActionEvent event)
> >                 {
> >                         if
> (event.getSource().equals(Butao))
> >                         try
> >                         {
> >                                        
> ButtonPushed= baseText.getText();
> >
> >                                         Socket
> Sockete = null;
> >                                         Sockete 
> new Socket("master", 5050);
> >                                         //
> Serialize today's date to a outputstream associated
> to the
> > socket
> >
> >                                        
> OutputStream o = Sockete.getOutputStream();
> >                                        
> ObjectOutput s = new ObjectOutputStream(o);
> >
> >                                        
> s.writeObject(ButtonPushed);
> >                                         s.flush();
> >                                         s.close();
> >
> >                         }
> >                         catch (Exception e)
> >                         {
> >                                        
> erro=e.getMessage();
> > //                                     
> System.out.println("Error during serialization");
> > //                                     
> System.exit(1);
> >                         }
> >
> >
> >                         repaint();
> >                 }
> >         }
> >         public void paint(Graphics g)
> >         {
> >                 if (ButtonPushed != null)
> >                         g.drawString("o erro foi
> :"+ erro, 5,100);
> >         }
> >
> >
> > }
> >
> > thanks in advance
> > Henrique Proença
> >
> > ---
> > Wrox Professional Wireless Developer Conference,
> Amsterdam, July 10-12. Covering application of WAP,
> XML, ASP, Java and C++ to wireless computing, choose
> from 40+ technical sessions delivered by industry
> experts:
>
http://www.wroxconferences.com/ConferenceHome.asp?ConfID=9
> > ---
> > You are currently subscribed to pro_java_server
> as: aseem@o...
> $subst('Email.Unsub')
> 
> 
> ---
> Wrox Professional Wireless Developer Conference,
> Amsterdam, July 10-12. Covering application of WAP,
> XML, ASP, Java and C++ to wireless computing, choose
> from 40+ technical sessions delivered by industry
> experts:
>
http://www.wroxconferences.com/ConferenceHome.asp?ConfID=9
> imran_zafar@y...
> $subst('Email.Unsub')
> 


__________________________________________________
Do You Yahoo!?
Send instant messages with Yahoo! Messenger.
http://im.yahoo.com/

  Return to Index