Sockets problem

Hi ,
I written a server class that simply writes the numbers and the client simply reads those numbers and prints them. When I run the both client and server on tha same machine there is no data loss found. But when I run the server on different machine than client I found heavy dataloss.(while theserver written numbers from 1-9000 the client is able read only 6000 plus). The data loss is increased when the data read from the server socket created by the VB application. Here with i am pasting the code snippet for the Server and the Client java files . Please help me in solving this problem.
Client.java
import java.net.*;
import java.io.*;
public class Client
     static Socket client = null;
     ObjectInputStream is = null;
     public Client() throws Exception
          client = new Socket("rajsekhar",3333);
          is = new ObjectInputStream (client.getInputStream());
          while(true){
               Integer in = (Integer)is.readObject();
               System.out.println(in.toString());
     public static void main(String[] args) throws Exception
          new Client();
Server.java
import java.net.*;
import java.io.*;
public class Server
     public static void main(String[] args) throws Exception
          ServerSocket server = null;
          server = new ServerSocket(3333);
          Socket s = server.accept();
          ObjectOutputStream os = new ObjectOutputStream(s.getOutputStream());
          int i =1;
          while(true)
               os.writeObject(new Integer(i));
               System.out.println(i);
               i++;
please help me .
thanks in advance,
Sridhar Reddy .R

This has nothing to do with JSSE; please post in a more appropriate forum.

Similar Messages

  • Data socket problems with LVRT 8.2

     I am in the process of migrating to LV 8.2 from LV7.1.1. My system has 18 RT targets which send data to a Host PC through data socket (DS). The Host PC runs LV on Windows XP Pro.  With LV7.1.1 on both host and RT targets DS works perfectly. The RT targets update the host every 500 ms.
    I've taken a three-step process in the migration. First tests were done with the host migrated to LV8.2 while keeping the RTs at LV7.1.1. Result: the system worked perfect. Then I changed one RT to 8.2 keeping the rest the rest at LV7.1.1. Result: DS timed out before all the data could be sent to Host. Finally, all RTs were migrated to LVRT 8.2. Result: Only about 5 out of the 18 RTs report to the Host before DS times out. However, if only one RT target is used, i.e., the other 17 RTs are diasbled, communication is very fast. Is there a special setting that I need to make? Btw, the roughly 5 RTs that report vary randomly from test to test, i.e., there is no bias towards any particular RTs.
    I am using the same source code developed under LV7.1.1, so the only changes made are the ones that take place when one opens LV7.1.1 code in LV8.2. Some VIs get converted in the process.
    Any ideas?
    Chatonda Mtika
    Algis Corp
    Vancouver, Canada

    Ben,
    I must say I am very surprised by Nadim's email. His point, which I must say I don't agree with, was made quite clear to me yesterday during a conference call between my team and the NI team comprising Chris, Nadim, and Avinash. So I don't know what purpose this morning's email is supposed to serve. Be that as it may, I think NI has gotten it wrong here. I do not think it should be one or the other. The discussion forum is a much wider forum comprised of people with varying experiences - not just NI employees. That is precisely why I posted my problem to the forum: to tap into the vast experiences of the discussants. But when I did not get any responses after I had posted answers to Nadim's questions, I decided to make a formal service request to NI, all perfectly legal. So I was really surprised when I was being blamed for tying up NI resources on one problem. I believe the resource allocation issue should be NI's to solve, not mine. I have no way of knowing that NI had formally assigned somebody to my problem. What if nobody from NI responds, am I allowed to make a service request to NI? My feeling is that NI's logic is flawed here, assuming Nadim's views are NI's views.
    Thanks,
    Chatonda Mtika
    Algis Corporation
    Vancouver, Canada

  • Serversock/socket problem pls Help

    Hi all,
    I have a serversocket that accepts client's connections, reads from this stream, processes the data and sends back response to the client. This works fine for a standard scenario.
    The problem occurs if for some reason the client looses connection after writing to the serversocket. The server behaves as if nothing happens and sends back the response. I want the server to be able to detection any connection loss and report back. My code snippet is shown below
    ServerSocket server;
    Socket conn;
    BufferedReader input;
    PrintWriter out;
    try{
    server= new ServerSocket(4550,10);
    conn=server.accept();
    input = new BufferedReader(new InputStreamReader(conn.getInputStream()));
    String data=input.readLine();
    process data .....
    out = new PrintWriter(conn.getOutputStream(), true);     
    out.println(processed_data);
    }catch(IOException e){
    e.printStackTrace();
    }finally{
    try{
    input.close();
    out.close();
         conn.close();
         }catch(Exception uncaught){}
    If during process data, the client looses connection, the program behaves as if the connection still exist. Any suggesion would be highly appreciated
    Regards
    Tim

    err, yeah, i got that bit....
    and there is nothing, nothing at all in java, C, C++, any and i mean ANY TCP/IP programming that can tell if the client has been unplugged without trying to send something to it
    you can use a keepAlive in Socket to automatically occasionally send a dummy packet (for which it expects a response)
    but apart from that the Socket cannot know it is not connected unless it recieves indication from the client (the end that is closed first sends a FIN packet and the other end replies with ACK FIN)
    a pair of Sockets connectd through a network does not get a permanent physical connection, they give the impression of such by exchanging packets with sequence numbers and ack numbers coresponding to the last packet recived.
    if neither Socket has nothing to send, nothing is sent and it is assumed that the connection is still valid, so isConnected() will return true unless it actually knows that the client has closed the connection or an Exception occured when it tried to send something
    isConnected() does not test the connection, just reports true if it has been connected and there has not been an IOException or either end has closed
    maybe you could explain why you need to avoid sending the response if the client has been unplugged?

  • Create OPC I/O server and front panel data socket problem

    Hi all!
    I installed the NI OPC server. When I try to create a new server I/O in a LabVIEW project I don't see the "OPC client" possibility.
    Is something software missing? 
    Other question: I tryed to connect to OPC server using front panel data socket but my problem is same. When I click the numeric control and I go to the "data operation" menu there is no possibility to make data socket connection. 
    I don't know what is the problem.
    I attached two pictures about my problem. 
    Solved!
    Go to Solution.

    Dear vajasgeri1,
    do you have LabVIEW DSC module installed? Without it you will not have the OPC client funtionality.
    And to configure DataSocket binding you need to go to the Data Binding tab in the Properties of a control.
    BR,
    Mateusz Stokłosa
    Applications Engineer
    National Instruments

  • Socket Problem, Problem about printing the response from server

    Or even I am not sure if there is a response from server. My code is like that
                   //Connection between, httpProxy and target adress
                   Socket clientSocket= new Socket("some host", 80);
                   DataOutputStream outToServer= new DataOutputStream(clientSocket.getOutputStream());
                   BufferedReader inFromServer= new BufferedReader(new     InputStreamReader(clientSocket.getInputStream()));
                   //The first way
                   //outToServer.writeBytes("GET http://www.somehost.com/ HTTP/1.1"+ '\n');
                   //System.out.println("FROM SERVER: "+inFromServer.readLine());
                   //The second way
                   PrintWriter out_writer = new PrintWriter(outToServer, false);
                   out_writer.println("GET http://www.somehost.com/ HTTP/1.1");
                   out_writer.println("Host: localhost:80");
                   out_writer.println("Connection: Close");
                   out_writer.println();
                                        //The second way cont.
                   String s = null;
                   while ((s = inFromServer.readLine()) != null)
                   System.out.println(s);
                   inFromServer.close();There are the two ways that I tried, and both of them didn't work. Why they are not working ? How can I solve it ?

    problem is solved, the reason it doesn't work is i didn't write the parts correctly. I mean it should be exactly the same packetIf you mean that the entire request must be sent in a single IP packet, this isn't true.
    and host name must also be exactly sent to server.Of course.
    They must be like in the wireshark.No. The actual data you send must be the same, but the server has no way of telling about what the IP packet looks like or how many there were.
    One of your problems is that newlines in HTTP are defined as \r\n. In one case you're just using \n and in the other case you're using whatever the platform line terminator is. Neither is correct.

  • Datagram Socket Problem !!!!!!!!!!!!!!!

    Hi to All ,
    I am facing problem regarding the Datagram Socket Programming .
    I wana to make a java program that is using the datagram socket. I wana to retrive the IP Address of all the machines that are connected in a local network by using the datagram Socket !!!!!!!!!!!!!!
    As i am new in java Socket Programming , Can any body help me How am i sends a Broadcast Packet to all the machines that are connected in a local network , so that i retrieve the IP Address of all the machines that are presented in a local network
    Please give the Solution

    You can't use any Java to find all the machines on your network (whatever that means). You will need to shell out and parse the output from the shell.
    If you want to simply use datagram sockets to send UDP broadcasts, the Javadoc covers it in some detail.
    However, UDP is called a "send and pray" protocol - you send the message and pray that the client receives it. Also, there is no acknowledgement from the client when the message is received. So, in a nutshell, you cannot use multicasts to find clients.
    You need to use some other protocols in the TCP/IP stack for finding machines on the network - and Java does not have any pre-built support for these.

  • File transfer via socket problem (with source code)

    I have a problem with this simple client/server filetransfer program. When I run it, only half the file is transfered via the net? Can someone point out to me why this is happening?
    Client:
    import java.net.*;
    import java.io.*;
         public class Client {
         public static void main(String[] args) {
              // IPadressen til server
              String host = "127.0.0.1";
              int port = 4545;
              //Lager streams
              BufferedInputStream fileIn = null;
              BufferedOutputStream out = null;
              // Henter filen vi vil sende over sockets
              File file = new File("c:\\temp\\fileiwanttosend.jpg");
    // Sjekker om filen fins
              if (!file.exists()) {
              System.out.println("File doesn't exist");
              System.exit(0);
              try{
              // Lager ny InputStream
              fileIn = new BufferedInputStream(new FileInputStream(file));
              }catch(IOException eee) {System.out.println("Problem, kunne ikke lage fil"); }
              try{
              // Lager InetAddress
              InetAddress adressen = InetAddress.getByName(host);
              try{
              System.out.println("- Lager Socket..........");
              // �pner socket
              Socket s = new Socket(adressen, port);
              System.out.println("- Socket klar.........");
              // Setter outputstream til socket
              out = new BufferedOutputStream(s.getOutputStream());
              // Leser buffer inn i tabell
              byte[] buffer = new byte[1024];
              int numRead;
              while( (numRead = fileIn.read(buffer)) >= 0) {
              // Skriver bytes til OutputStream fra 0 til totalt antall bytes
              System.out.println("Copies "+fileIn.read(buffer)+" bytes");
              out.write(buffer, 0, numRead);
              // Flush - sender fil
              out.flush();
              // Lukker OutputStream
              out.close();
              // Lukker InputStrean
              fileIn.close();
              // Lukker Socket
              s.close();
              System.out.println("File is sent to: "+host);
              catch (IOException e) {
              }catch(UnknownHostException e) {
              System.err.println(e);
    Server:
    import java.net.*;
    import java.io.*;
    public class Server {
         public static void main(String[] args) {
    // Portnummer m� v�re det samme p� b�de klient og server
    int port = 4545;
         try{
              // Lager en ServerSocket
              ServerSocket server = new ServerSocket(port);
              // Lager to socketforbindelser
              Socket forbindelse1 = null;
              Socket forbindelse2 = null;
         while (true) {
         try{
              forbindelse1 = server.accept();
              System.out.println("Server accepts");
              BufferedInputStream inn = new BufferedInputStream(forbindelse1.getInputStream());
              BufferedOutputStream ut = new BufferedOutputStream(new FileOutputStream(new File("c:\\temp\\file.jpg")));
              byte[] buff = new byte[1024];
              int readMe;
              while( (readMe = inn.read(buff)) >= 0) {
              // Skriver filen til disken ut fra input stream
              ut.write(buff, 0, readMe);
              // Lukker ServerSocket
              forbindelse1.close();
              // Lukker InputStream
              inn.close();
              // flush - sender data ut p� nettet
              ut.flush();
              // Lukker OutputStream
              ut.close();
              System.out.println("File received");
              }catch(IOException e) {System.out.println("En feil har skjedd: " + e.getMessage());}
              finally {
                   try {
                   if (forbindelse1 != null) forbindelse1.close();
                   }catch(IOException e) {}
    }catch(IOException e) {
    System.err.println(e);
    }

    Hi!!
    The problem is at this line:
    System.out.println("Copies "+fileIn.read(buffer)+" bytes");
    Just comment out this line of code and see the difference. This line of code causes another "read" statement to be executed, but you are writing only the data read from the first read statement which causes approximately half the file to be send to the server.

  • Reading data from socket problem

    Hello;
    I have implemented a multiplayer game with server java and client flash. I have a socket connection and I get(wait) an encripted data from server. However sometimes I can't get data from server. I know that server is sending the data but I can't see the data on the socket.
    Sometimes I cannot get the data in one chunk but I have solved that problem(I hope).. Here is my code:
    private function onSocketData(event:ProgressEvent = null) {
         try {
              var input:String = "";
               var  byteArray = new ByteArray();
              socket.readBytes(byteArray, 0, socket.bytesAvailable);
               input+= byteArray.toString();
              queueOrg.addToMsgQueue(input);
         } catch (error:Error) {
              trace("SocketConnector -> onSocketData : "+error);
    Thanks...

    And don't use ready() or available as a test for end of stream like that. That's not what it's for. (What is is for is a moot question.) Using it like that is a recipe for losing data.

  • MySQL socket problems after system update

    I have been using my new Mac Mini Snow Leopard server as Squeezebox Server for over a month wihtout problems. After a system update this weekend I started to get MySQL socket errors after reboot.
    Started; log sequence number 0 43655
    091213 17:10:04 [ERROR] Can't start server : Bind on unix socket: Invalid argument
    091213 17:10:04 [ERROR] Do you already have another mysqld server running on socket: /Users/admin/Library/Caches/Squeezebox/squeezebox-mysql.sock ?
    091213 17:10:04 [ERROR] Aborting
    Although I have posted this issue to the Squeezebox forum (http://forums.slimdevices.com/showthread.php?t=72510) where it primarily belongs to I wanted to hear if anyone maybe had an idea what recent changes in Apple updates could cause this? Maybe someone else has similar MySQL problems with other installations? I am a bit desperate by now so any idea or hint is appreciated.

    Here was my solution/workaround for this issue to the rest of us poor fellas that have too fight around with Squeezebox server from time to time:
    I setup SBS to use the the standard MySQL installation on Mac OS X SL Server since I could get it to run without problems from Server Admin. Here are the instruction from the SBS Wiki:
    http://wiki.slimdevices.com/index.php/ExistingMySQLInstance
    However, I had to deviate a bit from that in order to make it work since it seems a bit outdated.
    First deviation was necessary for the MySQL access privileges. Notice the extra grant to slimserver@localhost. Don't ask me why but this worked. I do also not know whether both grants would be necessary because I haven't tried it. Feel free to improve it:
    # mysql -u admin_user -p
    Enter password: admin_password
    Welcome to the MySQL monitor.
    Commands end with ; or \g.
    Your MySQL connection id is 103 to server version: 5.0.24a-log
    Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
    mysql> create database slimserver;
    Query OK, 1 row affected (0.22 sec)
    mysql> grant all on slimserver.* to slimserver identified by 'slimserver_password';
    Query OK, 0 rows affected (0.13 sec)
    mysql> grant all on slimserver.* to slimserver@localhost identified by 'slimserver_password';
    Query OK, 0 rows affected (0.13 sec)
    mysql> flush privileges;
    Query OK,
    mysql> quit
    There were also slight differences necessary in the preferences setup because MySQL socket location was different from the standard one. Here are my db entries ~/Library/Application Support/Squeezebox/server.prefs:
    dbpassword: slimserver_password
    dbsource: dbi:mysql:database=slimserver;mysql_socket=/var/mysql/mysql.sock
    dbusername: slimserver
    Notice the extra mysql_socket configuration.

  • Data Sockets Problem

    Hi,
    I have written an applet with the following code that opens a simple socket. The problem is that I can only run one copy of the applet at once or I get an IOException can not create socket. Can any help me out
    Thanks for any help
    Joolz
    //// Start Code ////
    public tcpip(InetAddress ipa, int port)
    Socket _given = null;
    try
    _given = new Socket(ipa.getHostAddress(),port);
    catch(IOException e) {System.out.println("Error creating socket..");
        return;
    //// End Code ////

    Hi,
    Here is the error message, I don't have access to the server.
    Error creating socket java.net.connectException Connection refused connect.
    Thanks
    Joolz

  • Sockets problem under 1.4

    After upgrading to version 1.4 of the Java runtime, several of our users experience the following problem. Some of the data sent from the server seems to disappear from the socket. If I snoop on the machine, I can see the data coming in, but if I dump the raw bytes directly from the socket to a file, the data is not there. I appreciate any help. Thanks.
    -Pete Spiro

    I think I read somewhere that there are Socket bugs in 1.4. You should check out the bug list to see if I'm right or not, and if it pertains to your problem.

  • Sockets problem HELP!!

    I am trying to create a peer-to-peer messager using Sockets. I have a Listener class that listens for connections and accepts them and creates a new socket for each connection and also calls a ChatHandler which is passed the new socket. Exept the StartConv class which connects to the listener class initially never finds out about the new Socket and thinks it is still connected to the listener port :(( Here is some of the code i am trying to use for each of the classes:-
    Listener
    public class Listener implements Runnable {
      public void run () {
      try{
      listen();
    }catch(Exception e){
    System.out.println("Error in listener:"+e );
      public static void listen() throws IOException{
        int port = 4444;
        ServerSocket server = new ServerSocket (port);
        try{
        System.out.println("Listening...");
             while (true) {
             System.out.println("Listening...11");
             Socket client = server.accept ();
             System.out.println ("Accepted from " + client.getInetAddress ());
             ChatHandler handler = new ChatHandler (client);
             handler.start ();
      }catch (IOException ex){
      System.out.println("Error in listener"+ex);
    ChatHandler
    public class ChatHandler extends JFrame implements Runnable {
      protected Socket socket;
      public ChatHandler (Socket socket) {
        this.socket = socket;
      protected DataInputStream dataIn;
      protected DataOutputStream dataOut;
      protected Thread listener;
      public void start () {
      System.out.println("Entered ChatHandler.start()");
          try {
            dataIn = new DataInputStream
              (new BufferedInputStream (socket.getInputStream ()));
            dataOut = new DataOutputStream
              (new BufferedOutputStream (socket.getOutputStream ()));
            listener = new Thread (this);
            listener.start ();
            run();
          } catch (IOException ignored) {
      public synchronized void stop () {
        if (listener != null) {
          try {
            if (listener != Thread.currentThread ())
              listener.interrupt ();
            listener = null;
            dataOut.close ();
          } catch (IOException ignored) {
      public void run () {
      System.out.println("Entered ChatHandler.run()");
    try{
            String message = dataIn.readUTF ();
       }catch(IOException e) {   
       System.out.println("Problem receiving message: dataIn.readUTF");
            String title = "Conversation from "+socket.getInetAddress();
        JFrame cframe = new JFrame(title);
        // Create a component to add to the frame
        JPanel top=new JPanel();
        JPanel bottom=new JPanel();
        TextArea conv = new TextArea(10,75);
        TextArea msg = new TextArea(8,75);
    top.add(conv);
    bottom.add(msg);
        // Add the component to the frame's content pane;
        // by default, the content pane has a border layout
        cframe.getContentPane().add(top, BorderLayout.NORTH);
        cframe.getContentPane().add(bottom, BorderLayout.CENTER);
        // Show the frame
        cframe.setSize(600, 500);
        cframe.setVisible(true);
        stop ();
    StartConv
    public abstract class StartConv extends JFrame implements Runnable {
    public static void run (String userip){
    try{
    connect(userip);
    }catch(Exception e){
    System.out.println("Error in StartConv:"+e);
    showframe();
    public static void showframe(){
    String title = "Frame Title";
        JFrame frame = new JFrame(title);
        // Create a component to add to the frame
        JPanel top=new JPanel();
        JPanel bottom=new JPanel();
        TextArea conv = new TextArea(10,75);
        TextArea msg = new TextArea(8,75);
    top.add(conv);
    bottom.add(msg);
        // Add the component to the frame's content pane;
        // by default, the content pane has a border layout
        frame.getContentPane().add(top, BorderLayout.NORTH);
        frame.getContentPane().add(bottom, BorderLayout.CENTER);
        // Show the frame
        frame.setSize(600, 500);
        frame.setVisible(true);
      protected DataInputStream dataIn;
      protected DataOutputStream dataOut;
      protected Thread listener;
    public static void connect (String userip) throws IOException {
          String host=userip;
          int port=4444;
          Socket socket = new Socket (host, port);
          try {
             DataInputStream dataIn = new DataInputStream
              (new BufferedInputStream (socket.getInputStream ()));
             DataOutputStream dataOut = new DataOutputStream
              (new BufferedOutputStream (socket.getOutputStream ()));
          } catch (IOException ex) {
            socket.close ();
            throw ex;
          Thread listener = new Thread ();
          listener.start ();
      }

    It says at the top :) think i posted too much code but that way everyone knows exactly what is happening. Cant get the StartConv class to commmunicate with the ChatHandler basically

  • Sockets Problem / sort of Echoing Server

    Hey all, basically the problem i got is related to sockets, client program freezes up once i press the button 'send', Mainly all im trying to do right now is have a client send text to the server, then the server sends back whatever the client sent and this is then shown on the clients screen..
    The code i got is
    public class Server {
         public static void main(String[] args){
              try {
                   ServerSocket sSocket = new ServerSocket(3000);
                   Socket clientSocket = sSocket.accept();
                   BufferedReader fromClient = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
                   PrintWriter toClient = new PrintWriter(clientSocket.getOutputStream(), true);
                   String fClient;
                   while((fClient = fromClient.readLine())!= null){
                        toClient.println(fClient);
              }catch(IOException e) {
                   System.err.println(e);
    }And for the client class
    public class Client extends JFrame implements ActionListener {
         JTextArea result;
         JTextField text;
         Socket socket;
         public Client(){
              super("Client");
              try{
                   socket = new Socket("localhost", 3000);
              } catch (UnknownHostException e){
                   System.err.println("Unknown Host");
              } catch (IOException e) {
                   System.err.println("Exception");
              JPanel panel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
              result = new JTextArea(13,10);
              JButton send = new JButton("Send");
              text = new JTextField(19);
              send.addActionListener(this);
              panel.add(text);
              panel.add(send);
              add(new JScrollPane(result), BorderLayout.NORTH);
              add(panel, BorderLayout.SOUTH);
              setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              setSize(300,300);
              setVisible(true);          
         public void actionPerformed(ActionEvent e) {
              String fServer = null;
              BufferedReader fromServer = null;
              PrintWriter toServer = null;
              String aCommand = e.getActionCommand();
              if(e.getSource() instanceof JButton){
                   if(aCommand.endsWith("Send")) {
                        try {
                             fromServer = new BufferedReader(new InputStreamReader(socket.getInputStream()));
                             toServer = new PrintWriter(socket.getOutputStream());
                        }catch(IOException e1){
                             System.err.println("Exception occured");
                        toServer.println(text.getText());
                        try{
                             fServer = fromServer.readLine();
                        }catch (IOException e1) {
                             System.err.println("Error Recievieng Result");
                        result.append(fServer);
    }However after debugging the application, i think the main problem comes from the server side, mainly the while loop which keeps looping to see if the input recieved is null, i think the problem why the client freezes up is because nothing is being sent therefore the loops keeps going on in circles, hence not supplying the client with any text..
    I would appreciate if someone could give me some help how to fix this problem
    Thanks

    What else could the server do? There's no problem there. The problem is that you're calling network code inside an actionPerformed method. This freezes your GUI because the method is invoked within the AWT thread, which handles all the events on the GUI. As your code is blocked in network operations, no GUI events can be processed.
    Do the network operations in a separate thread.

  • Applet socket problem in client-server, urgent!

    Dear All:
    I have implemented a client server teamwork environment. I have managered to get the server running fine. The server is responsible for passing messages between clients and accessing Oracle database using JDBC. The client is a Java Applet. The code is like the following. The problem is when I try to register the client, the socket connection get java.security.AccessControlException: access denied(java.net.SocketPermission mugca.its.monash.edu.
    au resolve)
    However, I have written a Java application with the same socket connection method to connect to the same server, it connects to the server without any problem. Is it because of the applet security problem? How should I solve it? Very appreciate for any ideas.
    public class User extends java.applet.Applet implements ActionListener, ItemListener
    public void init()
    Authentication auth = new Authentication((Frame)anchorpoint);
    if(auth.getConnectionStreams() != null) {
    ConnectionStreams server_conn = auth.getConnectionStreams();
    // Authenticates the user and establishes a connection to the server
    class Authentication extends Dialog implements ActionListener, KeyListener {
    // Object holding information relevant to the server connection
    ConnectionStreams server_conn;
    final static int port = 6012;
    // Authenticates the user and establishes connection to the server
    public Authentication(Frame parent) {
    // call the class Dialog's constructor
    super(parent, "User Authentication", true);
    setLocation(parent.getSize().width/3, parent.getSize().height/2);
    setupDialog();
    // sets up the components of the dialog box
    private void setupDialog() {
    // create and set the layout manager
    //Create a username text field here
    //Create a password text field here
    //Create a OK button here
    public void actionPerformed(ActionEvent e) {
    authenticateUser();
    dispose();
    // returns the ConnectionStreams object
    public ConnectionStreams getConnectionStreams() {
    return(server_conn);
    // authenticates the user
    private void authenticateUser() {
    Socket socket;
    InetAddress address;
    try {
    // open socket to server
    System.out.println("Ready to connect to server on: " + port);
    socket = new Socket("mugca.its.monash.edu.au", port);
    address = socket.getInetAddress();
    System.out.println("The hostname,address,hostaddress,localhost is:" + address.getHostName() + ";\n" +
    address.getAddress() + ";\n" +
    address.getHostAddress() + ";\n" +
    address.getLocalHost());
    catch(Exception e) {
    displayMessage("Error occured. See console");
    System.err.println(e);
                                  e.printStackTrace();
    }

    Hi, there:
    Thanks for the help. But I don't have to configure the security policy. Instead, inspired by a message in this forum, I simply upload the applet to the HTTP server (mugca.its.monash.edu.au) where my won server is running. Then the applet is download from the server and running fine in my local machine.
    Dengsheng

  • Ipaq Socket problems

    I'm running into the following problem while running a PersonalJava application on a Compaq ipaq 3600. The Java application tries to open a Socket connection to a server, then close the connection for a number of iterations
    (currently 300). However, when it reaches the iteration in the range of approximately 193-199, it throws a java.net.ConnectionException when it tries to create a new Socket. I am unable to get any Java application
    to create a new Socket after this happens, until I perform a soft reset of the ipaq. This happens every time I run the application. The server I'm currently connecting to is an apache webserver, but I have tried to connect to various servers (different host/port combinations) and the problem always occurs.
    It is occurring on both the Jeode and Sun WinCE PersonalJava beta 1.1 implementation.
    The following source code produces the problem:
    import java.io.*;
    import java.net.*;
    public class SocketTest {
    public static void main(String args[]) {
    Socket s1 = null;
    PrintWriter pw = null;
    try {
    FileOutputStream fos = new FileOutputStream("\\socketoutput.txt");
    pw = new PrintWriter(fos, true);
    } catch (IOException ioe) {
    System.exit(0);
    try {
    for (int i = 1; i < 300; i++) {
    s1 = new Socket("192.168.0.57", 80);
    pw.println("Opened socket " + i);
    pw.println("socket is " + s1.toString());
    s1.close();
    pw.println("closed socket " + i);
    try {
    Thread.sleep(600);
    } catch (Exception e) {
    } catch (Exception e) {
    e.printStackTrace();
    e.printStackTrace(pw);
    if (s1 != null) {
    pw.println("Socket.toString(): " + s1.toString());
    pw.println("Exception message: " + e.getMessage());
    pw.close();
    System.out.println("At end");
    (Apologies for the indentation not appearing in the above code)
    The exception that is thrown when the Socket cannot be created is:
    java.net.ConnectException
         at java.net.PlainSocketImpl.connect (Native Method)
         at java.net.PlainSocketImpl.connect (bytecode 33)
         at java.net.PlainSocketImpl.connect (bytecode 9)
         at java.net.Socket.<init> (bytecode 96)
         at java.net.Socket.<init> (bytecode 9)
         at SocketTest.main (bytecode 15)
    Socket.toString(): Socket[addr=192.168.0.57/192.168.0.57,port=80,localport=1607]
    Exception message: null
    Has anyone else see anything like this? If so, is there a workaround? This is only a test application, the real-life application will involve a number of socket open/close operations during its lifetime, but this problem keeps occurring.
    Any help would be appreciated.
    thanks,
    Derek

    For anyone interested. The solution to this problem is located here.
    http://groups.yahoo.com/group/j2me-cdc/message/57

Maybe you are looking for

  • Invoking a method on an URL request?

    i want to invoke a method of a class on an URL request,such that the method can navigate the control to number of other pages .

  • Can't install a search plugin

    OS X 10.8.5, Firefox 24.5.0 1. Click on dropdown in Firefox's search field. 2. A list of installed search engine plugins appears along with "Manage Search engines...". Click this. 3. Click on "Get more search engines" 4. https://addons.mozilla.org/en

  • Please Help Connection Error

    This is going to be long so apologies in advance. Okay here goes. My computer is set to reset every time it's cut off; Meaning i have to reinstall my web browser every time i use it. This is not a problem, actually it's preferred. Anywho i use Firefo

  • I Deleted My Kernel.... Why, How, And How I Restored It [SOLVED]

    This has to be my all time biggest screw up to date since using Linux! WHY: I've had one of my Ubuntu installs hacked and patched to support  Nvidia GT220 HDMI audio out months ago, but thought I'd just wait for nvidia, alsa and/or the Linux kernel f

  • Tables data

    hi friends my colleague who has .net application has issue with database data so they want to test the data they want some table data for testing? how can i get data? can i use export and import or any other process pls let me know thanks for help