Client server problem

Hallo,
I have a client server architecture, where the server part is implemented as a SQLJ object in database. Client and server communicate via network sockets. The server process is started by a JDBC call to a member method of a server object.
Different clients call this method on different stored objects, so there are different server processes, running in different JVMs
Outside the database, I would realize my architecture with something like that:
public class Server extends Thread {
  public static void main (String[] args]) {
    ServerSocket listenSocket = null;
    try {
      listenSocket = new ServerSocket(PORT);
    catch (IOException exc) {
    Socket connectedSocket;
    while (true) {
      try {
        connectedSocket = listenSocket.accept();
        Server serverinstanz = new Server (connectedSocket);
        serverinstanz.start();
      catch (IOException exc) {}
}How I could implement this in a database? The client searches for a special server object in database and wants to connect to it. But not all of theses objects can create a ServerSocket. At the moment the clients themselves create a ServerSocket and the Server connects to them. But this can't be the best solution.
Thanks, Christian

1) Don't multipost - http://forum.java.sun.com/thread.jspa?threadID=5214646
2) Read http://forum.java.sun.com/help.jspa?sec=formatting before you post code the next time

Similar Messages

  • Client == server - problems with callbacks

    Hi everyone!
    I'm having trouble establishing bidirectional communication between a client and a server (code samples are below).
    Both classes (client & server) extend UnicastRemoteObject and implement Interfaces that are extending Remote. Now the client looks up the server and tries to register itself at the server by calling a method like this:
    remote_server.setClient(this);
    as long as I execute both programs in the same LAN this method-call works fine, but when client and server connect through internet I'm getting the following exception:
    ---------------------- Exception ------------------------>
    java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
         java.rmi.ConnectException: Connection refused to host: 192.168.0.3; nested exception is:
         java.net.ConnectException: Connection timed out
         at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:292)
    <---------------------- Exception ------------------------
    maybe helpful:
    - 192.168.0.3 is the client's LAN-IP
    - I am directly connected to the internet via ADSL-modem (no router)
    I searched the forums for several hours now, I read through the following tutorial,
    http://developer.java.sun.com/developer/onlineTraining/rmi/exercises/RMICallback/index.html
    but still I didn't find a solution.
    I already spent a lot of time developing this and I start to get desperate, so I hope someone of you out there can help me!
    pilord
    ==================== Codesamples =======================>
    public class ServerImpl extends UnicastRemoteObject implements Server {
    Client client;
    public ServerImpl() {
    LocateRegistry.getRegistry(1096).rebind("test",this);
    /* specified in Remote-Interface: Server*/
    public void setClient(Client client) {
    this.client = client;
    public class ClientImpl extends UnicastRemoteObject implements Client {
    public ClientImpl() {
    Server s = Naming.lookup("rmi://***.***.***.***:1096/test");
    s.setClient(this); // HERE is the trouble.
    <==================== Codesamples =======================

    Don't feel lost, crumb. Http tunnelling is not as complex as it seems. I just started using RMI at my new job here and in a couple of weeks I've already picked up on alot of what I needed to know. (I just posted a question myself on the same topic.) Basically what you have to do is set up a web server for RMI to talk to at the server side. It will work if the webserver is listening on port 80 with the rmiservlet.ServletHandler registered to respond to any path request of cgi-bin/java-rmi.cgi. In other words "cgi-bin/java-rmi.cgi" should be the servlet-mapping of the ServletHandler. The servlet merly acts as a proxy on behalf of the RMI client and fowards the request to the desired port on the server. If you know how to set up a servlet as the default web app then it is really a breeze. On the client side you only need to set the http.proxyHost and http.proxyPort system properties to the appropriate values for your proxy server. (I mistyped these property names in my prior post use what I have here as I just read it out of the RMI book.) Do a search on HTTP tunnelling and you should turn up dozens of hits. I have the source to the servlet if you need it. I've already modified it for my own purposes though it should still work for you. If you forego http tunnelling then you'll have to do a complete app rewrite to use another protocol because RMI just doesn't work through firewalls without it. Alternatively you can get down and dirty with some low level sockets coding (this is what I'm thinking I'll end up doing eventually) to get it working without standard RMI/HTTP but that's way more complex. Unfortunately it looks like your callback code will need to be rewritten unless you either go commercial or do the socket stuff. (There does seem to be a shareware product called rmi doves that would help you here.) I'll be happy to assits you in any way as you need help.
    Cliff

  • Help me to sort out the problem in this Simple Client - Server problem

    Hi all,
    I have just started Network programming in java . I tried to write simple Client and Server program which follows
    MyServer :
    package connection;
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.net.ServerSocket;
    import java.net.Socket;
    public class MyServer {
          * @param args
         public static void main(String[] args) {
              String ss ="";
              try {
                   ServerSocket sockServer = new ServerSocket(6000);
                   Socket clientLink = sockServer.accept();
                   System.out.println("Connection Established");
                   InputStreamReader isr = new InputStreamReader(clientLink.getInputStream());
                   BufferedReader bufReader = new BufferedReader(isr);
                   System.out.println("buf "+bufReader.readLine());
                   try {
                        while ((ss=bufReader.readLine())!=null) {
                             ss+=ss;
                        System.out.println("client message "+ss);
                   } catch (IOException e) {
                        System.out.println("while reading");
                        e.printStackTrace();
              } catch (IOException e) {
                   System.out.println("Can't able to connect");
                   e.printStackTrace();
    }MyClient:
    package connection;
    import java.io.IOException;
    import java.io.OutputStreamWriter;
    import java.io.PrintWriter;
    import java.net.Socket;
    public class MyClient {
          * @param args
         public static void main(String[] args) {
              try {
                   Socket client = new Socket("127.0.0.1",6000);
                   OutputStreamWriter osw = new OutputStreamWriter(client.getOutputStream());
                   PrintWriter pw = new PrintWriter(osw);
                   pw.write("hello");
              } catch (IOException e) {
                   System.out.println("Failed to connect");
                   e.printStackTrace();
    }I got this error message when I start my client program .
    Error message :
    Connection Established
    java.net.SocketException: Connection reset
         at java.net.SocketInputStream.read(Unknown Source)
         at sun.nio.cs.StreamDecoder.readBytes(Unknown Source)
         at sun.nio.cs.StreamDecoder.implRead(Unknown Source)
         at sun.nio.cs.StreamDecoder.read(Unknown Source)
         at java.io.InputStreamReader.read(Unknown Source)
    Can't able to connect
         at java.io.BufferedReader.fill(Unknown Source)
         at java.io.BufferedReader.readLine(Unknown Source)
         at java.io.BufferedReader.readLine(Unknown Source)
         at connection.MyServer.main(MyServer.java:27)I think this is very simple one but can't able to find this even after many times . please help me to sort out this to get start my network programming .
    Thanks in advance.

                   System.out.println("buf "+bufReader.readLine());Here you are reading a line from the client and printing it.
                   try {
                        while ((ss=bufReader.readLine())!=null) {
                             ss+=ss;
                        }Here you are reading more lines from the client and adding it to itself then throwing it away next time around the loop.
                        System.out.println("client message "+ss);... so this can't print anything except 'null'.
                   pw.write("hello");Here you are printing one line to the server. So the server won't ever do anything in the readLine() loop above. Then you are exiting the client without closing the socket or its output stream so the server gets a 'connection reset'.

  • PLEASE HELP me with my Client/Server problem !!!

    I have a method that can currently only recieve one file at a time, but I need it to be able to recieve multiple incomming files. My problem is that it can recieve the first file, but when the send file is sent to this method, it freezes. Can somebody please help me debug it!! I need to get this working by tonight. Thanks!
    public class A implements Runnable {
            String hostname;
            private Thread runner;
            public A () {}
            public void receive() throws IOException {
                    try {
                            while (true) {
                                    Socket s = ss.accept();            
                                    s.close();
                    } catch (Exception e) {
                            System.out.println(e);
            public void run() {
                    try {
                            ServerSocket ss = new ServerSocket(1111);
                            while (true) {
                                    receive();
                    } catch (IOException ioe) {
                            System.out.println("IOException in run()\n" + ioe.getMessage());
            private void stop() {Runner = null;}
            public void request(String fileName) {
                    if(runner == null) {
                   runner = new Thread(this);
                   runner.start();
                            try {
                                    send(fileName);
                            } catch (Exception e) {
                                System.out.println("Exception in run()\n" + e.getMessage());
    }

    you have a while(true) in your receive, so you accept the socket, do the // ... stuff, close it, and then sit there waiting to accept another one again. Am I seeing that correctly?

  • Sending a text file Client/Server problem

    Hi,
    I have two java classes (A.java and B.java). i would like to send the text file (something.txt) from A to B. Can somebody please show me how to do so? I know it is incomplete, but i really need help since im new to this. I dont know how to send and how to accept the file. Here is what i have so far:
    import java.net.*;
    import java.io.*;
    import java.lang.*;
    public class A {
            private static String hostname;                  //host name
            private static final int portA = 1111;           //source port number
            private static int portB;                        //destination port number
            private static ServerSocket s;
            private static Socket socket;
            private static BufferedReader br;    
            String fileName = "something.txt";
            public A () {
            public static void send() {
                    System.out.println("Send method");
                    try {
                        System.out.print("> Enter Hostname: ");
                     hostname = br.readLine();
                     System.out.print("> Enter Port Number: ");
                        portB = Integer.valueOf(br.readLine()).intValue();
                catch(IOException e){}
            public static void main(String args[]) throws IOException {
    import java.net.*;
    import java.io.*;
    import java.lang.*;
    public class B {
            private static String hostname;                  //host name
            private static final int portB = 2222;           //source port number
            private static ServerSocket s;
            private static Socket socket;
            private static BufferedReader br;    
            public B () {
            public static void recieve() {
                 //code to recieve the text file here?
            public static void main(String args[]) throws IOException {
    }I really appriciate any code to help me out. Thanks

    Check out the link shown below:
    http://forum.java.sun.com/thread.jsp?forum=33&thread=66616
    If that doesn't answer your question, search this site for Upload
    ;o)
    V.V.

  • Problem using the File Dialog Box in a Client/Server application

    I am developping a client-server application using Labview 5.1 . The application on the server acquires data from some instruments and saves it on file, while the application on the clients displayes such acquired data. For doing this I call some routines on the server via the "Open Application vi" (remote connection). All goes well except when I open on the server the "File Dialog Box vi" : in this case the application on the clients is blocked (is blocked the execution of the called vi on the server). Only when
    the File Dialog Box on the server is closed, the execution of the called vi on the server starts again.
    I need to use the File Dialog Box on the server, but I don' t want to stop at the same time
    the clients !!
    I need help for resolving such problem.
    Many thanks in advance !!!

    Hi!
    waldemar.hersacher wrote:
    "It seems that the VIs called by the clients are running in the user interface thread.
    A call to the file dialog box will call a modal system dialog. So LV can't go on executing VIs in the user interface thread."
    Are you sure? I think, that File Dialog, called by LabVIEW File Dialog from Advanced File Functions Palette doesn't blocking any cycles in subVI, which running in UI Thread. Look in my old example (that was prepared for other topic, but may be good for this topic too).
    2 linus:
    I think, you must a little bit reorganize you application for to do this. You must put your File Dialog into separated cycle. This cycle, of course, will be blocked when File Dialog appear on the screen. But other cy
    cle, which responsible for visualization will run continuosly at the same time...
    Attachments:
    no_block_with_file_open_dialog.zip ‏42 KB

  • 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

  • Problem to rewrite client/server MS Word report in Reports 10g

    Hi all,
    We are going to migrate 4.5 forms application to 10g and we have the following problem.
    In the old client/server application we are calling some DB function which returns the character string and we are writing this string into the text file (TEXT_IO). Afterwards the text file is formatted using MS WORD (called from the form with DDE.APP_BEGIN) and .DOT template file.
    In forms 10g in order to implement the same functionality we found two possible solutions:
    •     Generate the file on the OAS , transfer it to client machine with WEBUTIL and manually run MS WORD in the batch file and generate the report
    •     Generate the Oracle Report.
    We are more inclined to the second solution but in order to develop the report it should be based on some table or view or REF CURSOR. The called DB function contains six cursors and it will be very difficult to rewrite it with one cursor in order to use REF Cursor. In this case we have to use the temporary table but it doesn’t look as a best solution.
    What could be an alternative solution?
    Any help will be appreciated.
    Thanks
    Alex

    Bill and Kileen,
    Thanks both. That is just what was needed. I tested and it works fine now.
    The same is also mentioned in the User Guide / Release Notes that accompanied the toolkit.
    I happened to collect some other webpages and .pdf that talk of other issues. In case someone happens to need this (.zip file would be less than 1 MB), please feel free to write at [email protected]
    Best regards,
    Gurdas
    Gurdas Singh
    PhD. Candidate | Civil Engineering | NCSU.edu

  • An rmi client server design problem

    I am implementng a networked cards game in java using rmi . The server keeps track of the turn of the players and activates ther clients(on an applet) whose turn it is to play .
    Both client and server call each others methods.
    Prblem one :
    Right now if a a client disconnects , a process run through all the clients active and gets a remote exception on the server and removes ALL the 4 players i nthat particulat group. If I want to save the state and allow any player to contuniue from there , how will I do it?
    Problem 2:
    How do I keep track of the time a client takes to play.
    If he takes longer than say 5 mintes , I should disconnect him.

    There seem to be two issues at stake: <b>catching the remote exception</b> and <b>multithreading</b> your application on the server.
    When a client disconnects "suddenly" (without logging off via remote method call to alert server), the remote method call by the server to all <i>n</i> players triggers a remote exception that must be caught and dealt with accordingly (do I understand that it is causing the application to exit at present?) When caught, you must identify which player is "gone" and remove that client from the pool of client objects.
    Right now, it sounds as if the app is NOT multithreaded. You can create a low-priority thread that looks at a time variable for each player to determine its last moment of play. This means every successful remote call from client-server or vice-versa will update that client's 'lastplayed' variable with (long) System.currentTimeMillis() for example.

  • Client-Server side programing problem

    I designed a client-server program as seen below basis on serversocket and thread
    I use serversocket for making a host connection than people connect this socket via applet that i designed then they transffer data with socket.getInputStream() and socket.getOutputStream but it always happening between client and server how can i make theese streams transfer between clients is something like that possible if it is how?
    I couldnt send my hole java code because its too long and i wish i could explain my problem
        public void run()
            try
                servsocket = new ServerSocket(port);
                jTextArea1.append("Kullanici Girisi Bekleniyor.\n");
            catch(IOException e)
                jTextArea1.append("Sunucu Uzerinde Socket Acilamadi.\n");
                while(calisiyor)  //calisiyor variable is a boolean variable for checking if server is running
                    try
                    Socket sock = servsocket.accept();
                    background = new techsupportbackground(this,sock);
                    background.start();
                    catch(Exception e)
                        printstring("Hata:"+e);
                        break;
    this is the techsupportbackground classes run method it extends from thread
        public void run()
            if(!servicesetup()) return;
            support.printstring("Baglanti saglandi,kullanici basariyla giris yapti.");
            setPriority(MIN_PRIORITY);
            String sonmesaj = "";
            while(calisiyor)
                String mesaj = readinputline();
                if(mesaj == null) break;
                if (!sonmesaj.equals(mesaj))
                    support.printstring(username+"->"+mesaj);
                    sonmesaj = mesaj;
            cikis();
    and this is the client side program's run method
        public void run()
            try
                if(!doconnection())
                    client.printstring("Baglanti Saglanamadi:");
                    return;
            catch(Exception e)
                client.printstring("Baglanti Saglanamadi");
            while (calisiyor)
                String mesaj = readline();  //readline is the method which reads sockets input stream
                client.printstring(mesaj);
                    if (mesaj == null) break;
                    try {
                    Thread.sleep (client.timeupdate);
                    catch (InterruptedException e)
            if (server != null) closeserver();
            client.setdisconnected();
            client.printstring("Baglanti Koptu");

    I made two java file , one for server one for client
    server is working good openning the socket but the client is crashing when i attempt to connect to server
    here is my code if anyone could tell me where i made a mistake i would be very appreciate
    this is the client program
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import java.net.*;
    import javax.swing.*;
    import javax.swing.event.*;
    class client extends javax.swing.JFrame {
        private boolean baglandi;
        private MulticastSocket socket;
        private int port;
        private String ip;
        String username;
        private InetAddress group;
        private String msg;
        private DatagramPacket datawriter;
        private byte[] reader;
        private boolean calisiyor;
        private JScrollPane scrollpane;
        public client() {
            initComponents();
            this.setSize(490,450);
            jTextArea1.setEditable(false);
            jTextField2.setEditable(false);
            jButton2.setEnabled(false);
            jLabel3.setForeground(Color.RED);
            JPanel panel = new JPanel();
            panel.setLayout(new BorderLayout());
            panel.setBounds(0, 0, 480, 260);
            getContentPane().add(panel);
            scrollpane = new JScrollPane();
            scrollpane.getViewport().add(jTextArea1);
            panel.add(scrollpane,BorderLayout.CENTER);
            baglandi=false;
            ip="228.5.6.7";
            port=2222;
            try
            group = InetAddress.getByName(ip);
            msg ="";
            datawriter = new DatagramPacket(msg.getBytes(),msg.length(),group,port);
            calisiyor = false;
            catch(Exception e)
        private void initComponents() {
            jTextArea1 = new javax.swing.JTextArea();
            jLabel1 = new javax.swing.JLabel();
            jLabel2 = new javax.swing.JLabel();
            jTextField1 = new javax.swing.JTextField();
            jTextField2 = new javax.swing.JTextField();
            jButton1 = new javax.swing.JButton();
            jButton2 = new javax.swing.JButton();
            jButton3 = new javax.swing.JButton();
            jLabel3 = new javax.swing.JLabel();
            getContentPane().setLayout(null);
            addWindowListener(new java.awt.event.WindowAdapter() {
                public void windowClosing(java.awt.event.WindowEvent evt) {
                    exitForm(evt);
            getContentPane().add(jTextArea1);
            jTextArea1.setBounds(0, 0, 480, 260);
            jLabel1.setText("Kullanici Adi");
            getContentPane().add(jLabel1);
            jLabel1.setBounds(0, 270, 90, 15);
            jLabel2.setText("Mesaj");
            getContentPane().add(jLabel2);
            jLabel2.setBounds(0, 300, 60, 15);
            getContentPane().add(jTextField1);
            jTextField1.setBounds(100, 270, 290, 21);
            getContentPane().add(jTextField2);
            jTextField2.setBounds(100, 300, 290, 21);
            jButton1.setText("Gonder");
            jButton1.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton1ActionPerformed(evt);
            getContentPane().add(jButton1);
            jButton1.setBounds(400, 270, 80, 25);
            jButton2.setText("Gonder");
            jButton2.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton2ActionPerformed(evt);
            getContentPane().add(jButton2);
            jButton2.setBounds(400, 300, 80, 25);
            jButton3.setText("Durdur");
            jButton3.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton3ActionPerformed(evt);
            getContentPane().add(jButton3);
            jButton3.setBounds(400, 340, 80, 25);
            jLabel3.setText("Baglanti Saglanamadi");
            getContentPane().add(jLabel3);
            jLabel3.setBounds(0, 360, 130, 15);
            pack();
        private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
            durdur();
        private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
            printoutput();
        private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
            baslat();
        /** Exit the Application */
        private void exitForm(java.awt.event.WindowEvent evt) {
            System.exit(0);
         * @param args the command line arguments
        public static void main(String args[]) {
            new client().show();
        public void baslat()
            username = jTextField1.getText();
            try
                socket = new MulticastSocket(port);
                socket.joinGroup(group);
            catch(IOException e)
                jTextArea1.append("Guvenlik Engellemesi Sebebiyle Sunucuya Ulasilamadi.\n");
                return;
                    jTextArea1.append("Sunucuya Baglanildi");
                    baglandi = true;
                    calisiyor = true;
                    jLabel3.setText("Baglanti Saglandi");
                    jTextArea1.append("Sunucuya Basariyla Baglanildi\n");
                    jLabel3.setForeground(Color.GREEN);
                    jButton1.setEnabled(false);
                    jTextField1.setEditable(false);
                    jButton2.setEnabled(true);
                    jTextField2.setEditable(true);
                while (calisiyor)
                        String mesaj = readline();
                        printstring(mesaj);
                        if (mesaj == null) break;
        public void durdur()
            jTextField2.setEditable(false);
            jTextField1.setEditable(true);
            jButton2.setEnabled(false);
            jButton1.setEnabled(true);
            jLabel3.setText("Baglanti Saglanamadi");
            jLabel3.setForeground(Color.RED);
            try
                socket.leaveGroup(group);
            catch(Exception e)
        public void printoutput()
            try
            String mesaj = jTextField2.getText();
            jTextField2.setText("");
            writeline(username+":->"+mesaj);
            catch(Exception e)
                printstring("Veri Ulastirilamadi.");
        public void printstring(String s)
            jTextArea1.append(s+"\n");
        public void setdisconnected()
            jTextField2.setEditable(false);
            jTextField1.setEditable(true);
            jButton2.setEnabled(false);
            jButton1.setEnabled(true);
            jLabel3.setText("Baglanti Saglanamadi");
            jLabel3.setForeground(Color.RED);
            public String readline()
                byte[] buf = new byte[1000];
                DatagramPacket datapack = new DatagramPacket(buf,buf.length);
                try
                    socket.receive(datapack);
                    String mesaj = buf.toString();
                    return mesaj;
                catch(Exception e)
                    printstring("Sunucuya Ulasilamadi");
                    return null;
        public void writeline(String s) throws IOException
                try
                    msg = s;
                    socket.send(datawriter);
                    printstring(msg);
                catch(Exception e)
                    printstring("Mesaj ulastirilamadi.");
        // Variables declaration - do not modify
        private javax.swing.JButton jButton1;
        private javax.swing.JButton jButton2;
        private javax.swing.JButton jButton3;
        private javax.swing.JLabel jLabel1;
        private javax.swing.JLabel jLabel2;
        private javax.swing.JLabel jLabel3;
        private javax.swing.JTextArea jTextArea1;
        private javax.swing.JTextField jTextField1;
        private javax.swing.JTextField jTextField2;
        // End of variables declaration
    this is the server program
    import java.net.*;
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class techsupport extends javax.swing.JFrame implements ActionListener,Runnable {
        private MulticastSocket servsocket;
        private int port;
        private boolean calisiyor;
        private JScrollPane scrollpane;
        private techsupportbackground  background;
        private InetAddress group;
        public techsupport(String title) {
            super(title);
            initComponents();
            this.setSize(400,400);
            port=2222;
            jTextField1.addActionListener(this);
            jButton1.addActionListener(this);
            calisiyor=true;
            jTextArea1.setEditable(false);
            JPanel panel = new JPanel();
            panel.setLayout(new BorderLayout());
            panel.setBounds(0,10,400, 230);
            getContentPane().add(panel);
            scrollpane = new JScrollPane();
            scrollpane.getViewport().add(jTextArea1);
            panel.add(scrollpane,BorderLayout.CENTER);
                try
                group = InetAddress.getByName("228.5.6.7");
                catch(Exception e)
        private void initComponents() {
            jTextArea1 = new javax.swing.JTextArea();
            jButton1 = new javax.swing.JButton();
            jLabel1 = new javax.swing.JLabel();
            jButton2 = new javax.swing.JButton();
            jTextField1 = new javax.swing.JTextField();
            getContentPane().setLayout(null);
            addWindowListener(new java.awt.event.WindowAdapter() {
                public void windowClosing(java.awt.event.WindowEvent evt) {
                    exitForm(evt);
            getContentPane().add(jTextArea1);
            jTextArea1.setBounds(0, 10, 400, 230);
            jButton1.setText("Start");
            jButton1.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton1ActionPerformed(evt);
            getContentPane().add(jButton1);
            jButton1.setBounds(160, 260, 80, 25);
            jLabel1.setText("Port");
            getContentPane().add(jLabel1);
            jLabel1.setBounds(0, 240, 120, 15);
            jButton2.setText("Stop");
            jButton2.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton2ActionPerformed(evt);
            getContentPane().add(jButton2);
            jButton2.setBounds(250, 260, 90, 25);
            getContentPane().add(jTextField1);
            jTextField1.setBounds(0, 260, 130, 21);
            pack();
        private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
            try
            servsocket.close();
            jButton1.setEnabled(true);
            printstring("Port Kapatildi.");
            jTextArea1.setText("");
            catch(Exception e)
                printstring("Hata:"+e);
        private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
        private void exitForm(java.awt.event.WindowEvent evt) {
            System.exit(0);
        public static void main(String args[]) {
            new techsupport("Teknik Destek Sunucu").show();
        public void actionPerformed(ActionEvent e) {
            boolean status = false;
            String komut = e.getActionCommand();
                if (komut.equals("Start"))
                    try
                        port = Integer.parseInt(jTextField1.getText());
                        jButton1.setEnabled(false);
                    catch(NumberFormatException err)
                        jTextArea1.append("Hatali Port Numarasi"+"\n");
                        jButton1.setEnabled(true);                   
                    Thread uygulama = new Thread(this);
                    uygulama.start();
                else if (komut.equals("Stop"))
                    calisiyor=false;
                    dispose();
        public void run()
            try
                servsocket = new MulticastSocket(port);
                servsocket.joinGroup(group);
                jTextArea1.append("Kullanici Girisi Bekleniyor.\n");
            catch(IOException e)
                jTextArea1.append("Sunucu Uzerinde Socket Acilamadi.\n"+e.toString());
        public void printstring(String s)
            jTextArea1.append(s+"\n");
        // Variables declaration - do not modify
        private javax.swing.JButton jButton1;
        private javax.swing.JButton jButton2;
        private javax.swing.JLabel jLabel1;
        private javax.swing.JTextArea jTextArea1;
        private javax.swing.JTextField jTextField1;
        // End of variables declaration
    }

  • HELP - problem in running SSLSocket client/server application

    Hi,
    I want to create a SSLSocket based client/server application for this i have used EchoServer.Java and EchoClient.Java files. Both files are successfully compiled and when i ran EchoServer it throws an exception "Server certificate not found".
    I want to make a complete auto-controlled client/server application which will automatically gets certificate and all configuration itself from program because i will use both client and server application in as a servlet part.
    I did as per following instructions:
    -Create a keystore to hold the private and public keys for the server. e.g.
    keytool -genkey -keystore mykeystore -alias "myalias" -keypass "mysecret"
    -Export the X509 certificate from this store
    keytool -export -alias "myalias" -keystore mykeystore -file mycertfile.cer
    -Import this into a trustStore for the client
    keytool -import -alias "myalias" -keystore mytruststore -file mycertfile.cer
    -Run the server using the keystore
    java -Djavax.net.ssl.keyStore=mykeystore -Djavax.net.ssl.keyStorePassword="mysecret" EchoServer
    -Run the client using the truststore
    java -Djavax.net.ssl.trustStore=mytruststore -Djavax.net.ssl.trustStorePassword="mysecret" EchoClient localhost
    EchoServer.Java
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.io.PrintStream;
    import java.net.Socket;
    import javax.net.ssl.SSLServerSocket;
    import javax.net.ssl.SSLServerSocketFactory;
    public class EchoServer {
    public static int MYECHOPORT = 8189;
    public static void main(String argv[]) {
    try {
    SSLServerSocketFactory factory =
    (SSLServerSocketFactory) SSLServerSocketFactory.getDefault();
    SSLServerSocket sslSocket =
    (SSLServerSocket) factory.createServerSocket(MYECHOPORT);
    while (true) {
    Socket incoming = sslSocket.accept();
    new SocketHandler(incoming).start();
    } catch (IOException e) {
    e.printStackTrace();
    System.exit(30);
    class SocketHandler extends Thread {
    Socket incoming;
    SocketHandler(Socket incoming) {
    this.incoming = incoming;
    public void run() {
    try {
    BufferedReader reader =
    new BufferedReader(new InputStreamReader(incoming.getInputStream()));
    PrintStream out =
    new PrintStream(incoming.getOutputStream());
    boolean done = false;
    while (!done) {
    String str = reader.readLine();
    if (str == null)
    done = true;
    else {
    System.out.println("Read from client: " + str);
    out.println("Echo: " + str);
    if (str.trim().equals("BYE"))
    done = true;
    incoming.close();
    } catch (IOException e) {
    e.printStackTrace();
    EchoClient.Java
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.io.PrintStream;
    import java.net.InetAddress;
    import java.net.Socket;
    import java.net.UnknownHostException;
    import javax.net.ssl.SSLSocket;
    import javax.net.ssl.SSLSocketFactory;
    public class EchoClient {
    public EchoClient(){}
    public static final int MYECHOPORT = 8189;
    public static void main(String[] args) {
    /*if (args.length != 1) {
    System.err.println("Usage: Client address");
    System.exit(1);
    String sAddress="localhost";
    InetAddress address = null;
    try {
    //address = InetAddress.getByName(args[0]);
    address = InetAddress.getByName(sAddress);
    } catch (UnknownHostException e) {
    e.printStackTrace();
    System.exit(2);
    Socket sock = null;
    try {
    sock = new Socket(address, MYECHOPORT);
    } catch (IOException e) {
    e.printStackTrace();
    System.exit(3);
    SSLSocketFactory factory =
    (SSLSocketFactory) SSLSocketFactory.getDefault();
    SSLSocket sslSocket = null;
    try {
    sslSocket =
    (SSLSocket) factory.createSocket(sock, args[0], MYECHOPORT, true);
    } catch (IOException e) {
    e.printStackTrace();
    System.exit(3);
    BufferedReader reader = null;
    PrintStream out = null;
    try {
    reader = new BufferedReader(new InputStreamReader(sslSocket.getInputStream()));
    out = new PrintStream(sslSocket.getOutputStream());
    } catch (IOException e) {
    e.printStackTrace();
    System.exit(6);
    String line = null;
    try {
    // Just send a goodbye message, for testing
    out.println("BYE");
    line = reader.readLine();
    } catch (IOException e) {
    e.printStackTrace();
    System.exit(6);
    System.out.println(line);
    System.exit(0);
    } // Client
    Can anybody will please help me to solve my problem i am using JDK1.4.2_07
    Thanks in advance.

    Hi,
    I want to create a SSLSocket based client/server application for this i have used EchoServer.Java and EchoClient.Java files. Both files are successfully compiled and when i ran EchoServer it throws an exception "Server certificate not found".
    I want to make a complete auto-controlled client/server application which will automatically gets certificate and all configuration itself from program because i will use both client and server application in as a servlet part.
    I did as per following instructions:
    -Create a keystore to hold the private and public keys for the server. e.g.
    keytool -genkey -keystore mykeystore -alias "myalias" -keypass "mysecret"
    -Export the X509 certificate from this store
    keytool -export -alias "myalias" -keystore mykeystore -file mycertfile.cer
    -Import this into a trustStore for the client
    keytool -import -alias "myalias" -keystore mytruststore -file mycertfile.cer
    -Run the server using the keystore
    java -Djavax.net.ssl.keyStore=mykeystore -Djavax.net.ssl.keyStorePassword="mysecret" EchoServer
    -Run the client using the truststore
    java -Djavax.net.ssl.trustStore=mytruststore -Djavax.net.ssl.trustStorePassword="mysecret" EchoClient localhost
    EchoServer.Java
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.io.PrintStream;
    import java.net.Socket;
    import javax.net.ssl.SSLServerSocket;
    import javax.net.ssl.SSLServerSocketFactory;
    public class EchoServer {
    public static int MYECHOPORT = 8189;
    public static void main(String argv[]) {
    try {
    SSLServerSocketFactory factory =
    (SSLServerSocketFactory) SSLServerSocketFactory.getDefault();
    SSLServerSocket sslSocket =
    (SSLServerSocket) factory.createServerSocket(MYECHOPORT);
    while (true) {
    Socket incoming = sslSocket.accept();
    new SocketHandler(incoming).start();
    } catch (IOException e) {
    e.printStackTrace();
    System.exit(30);
    class SocketHandler extends Thread {
    Socket incoming;
    SocketHandler(Socket incoming) {
    this.incoming = incoming;
    public void run() {
    try {
    BufferedReader reader =
    new BufferedReader(new InputStreamReader(incoming.getInputStream()));
    PrintStream out =
    new PrintStream(incoming.getOutputStream());
    boolean done = false;
    while (!done) {
    String str = reader.readLine();
    if (str == null)
    done = true;
    else {
    System.out.println("Read from client: " + str);
    out.println("Echo: " + str);
    if (str.trim().equals("BYE"))
    done = true;
    incoming.close();
    } catch (IOException e) {
    e.printStackTrace();
    EchoClient.Java
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.io.PrintStream;
    import java.net.InetAddress;
    import java.net.Socket;
    import java.net.UnknownHostException;
    import javax.net.ssl.SSLSocket;
    import javax.net.ssl.SSLSocketFactory;
    public class EchoClient {
    public EchoClient(){}
    public static final int MYECHOPORT = 8189;
    public static void main(String[] args) {
    /*if (args.length != 1) {
    System.err.println("Usage: Client address");
    System.exit(1);
    String sAddress="localhost";
    InetAddress address = null;
    try {
    //address = InetAddress.getByName(args[0]);
    address = InetAddress.getByName(sAddress);
    } catch (UnknownHostException e) {
    e.printStackTrace();
    System.exit(2);
    Socket sock = null;
    try {
    sock = new Socket(address, MYECHOPORT);
    } catch (IOException e) {
    e.printStackTrace();
    System.exit(3);
    SSLSocketFactory factory =
    (SSLSocketFactory) SSLSocketFactory.getDefault();
    SSLSocket sslSocket = null;
    try {
    sslSocket =
    (SSLSocket) factory.createSocket(sock, args[0], MYECHOPORT, true);
    } catch (IOException e) {
    e.printStackTrace();
    System.exit(3);
    BufferedReader reader = null;
    PrintStream out = null;
    try {
    reader = new BufferedReader(new InputStreamReader(sslSocket.getInputStream()));
    out = new PrintStream(sslSocket.getOutputStream());
    } catch (IOException e) {
    e.printStackTrace();
    System.exit(6);
    String line = null;
    try {
    // Just send a goodbye message, for testing
    out.println("BYE");
    line = reader.readLine();
    } catch (IOException e) {
    e.printStackTrace();
    System.exit(6);
    System.out.println(line);
    System.exit(0);
    } // Client
    Can anybody will please help me to solve my problem i am using JDK1.4.2_07
    Thanks in advance.

  • Authetication problem in client/server app

    I am presently developing a client/server program, and I'm wondering what will be the best form of authentication. I plan to develop a protocol for the programs, any deviation leading to socket closure. I thought about signatures, but I don't think any body's ready to vouch for me(ie I don't know how to go about signatures). Is there any help?

    Learn about JAAS

  • Client/Server to Web-Based application Conversion

    Hi! Everyone,
    I have couple of questions for you guys.
    Our Client had recently upgraded Forms 4.5 to 6i to move from Client/Server based application to Web based application.
    They are using Forms Server 6i Patch Set 1, OAS 4.0.8.1, Windows NT Service Pack 5 and Oracle 7.3. They are facing the following error every now and then, when they run the forms,
    "FRM-92100: Your connection to the server was interrupted. This may be the result of a network error or a failure on the server.You will need to re-establish your session."
    Please let me know what might be causing the above error. The only problem i can think about might be Oracle 7.3. If i am right only Oracle 8 and above supports Forms 6i.
    Can anyone let me know some tips and/or techniques to upgrade Forms 4.5 to 6i. If there are any important settings/steps which we might have over looked during the upgrade, please list them.
    Any kind of help is greatly appreciated.
    Thanks,
    Jeevan Kallem
    [email protected]

    Most of the code is use with no changes at all.
    See otn.oracle.com/formsupgrade
    Regards
    Grant Ronald

  • Client/server program validation - is it possible?

    I've been mulling over this problem for a few days, and am starting to wonder if it's theoretically possible to find a solution. I'm not looking for specific code, this probably won't even be implemented in Java, I'm just wondering if there is a theoretical program model that would work in this situation.
    The short version:
    Validate the data generated by a client program, without knowing the original data.
    The long version:
    This is a "profiling" system for a MMOG (Massively Multiplayer Online Game). The MMOG is an internet based client/server graphical program where each client connects to the server and they interact with each other and the virtual world. They pay a monthly fee for access to the game. My program is not affiliated with the MMOG or its makers. I have no connections inside the company and cannot expect any cooperation from them.
    The "profiling" system is also a client/server model. The client program runs in the background while the MMOG client is active. It accesses the memory of the MMOG client to retrieve information about the player's character. Then, possibly on request or maybe immediately, it sends the character data to our server.
    What I want to validate is that the character data being sent is unmodified and actually comes from the MMOG program.
    I can reasonably expect that with mild encryption and some sort of checksum or digest, the vast majority of problems can be avoided. However, I am not sure it's possible to completely secure the system.
    I assume that the user has access to and knowledge of the profiler client and the MMOG client, their assembly code, and the ability to modify them or create new programs, leveraging that knowledge. I also assume that the user does not have access to or knowledge of either of the server applications - the MMOG server or mine.
    In a worst-case scenario, there are several ways they could circumvent any security I have yet been able to think of. For instance, they could set up a fake MMOG client that had the data they wanted in memory, and let the profiler access that instead of the real thing. Or, they could rewrite the profiler to use the data they wanted and still encrypt it using whatever format I had specified.
    I have been considering using some kind of buffer overflow vulnerability or remote execution technique that would allow me to run specific parts of the client program on command, or get information by request, something that could not be anticipated prior to execution and thus could not be faked. But this seems not only insecure for the client but also not quite solid enough, depending on how it was implemented.
    Perhaps a series of apparently random validation codes, where the client does not know which one actually is doing the validation, so it must honor them all. Again, this is very conceptual and I'm sure that I'm not explaining them very well. I'm open to ideas.
    If I don't come up with anything better, I would consider relying on human error and the fact that the user will not know, at first, the relevance of some of the data being passed between client and server. In this case, I would include some kind of "security handshake" that looks like garbage to the client but actually is validated on the server end. A modified program or data file would result in an invalid handshake, alerting the server (and me) that this client was a potential problem. The client would have no idea anything had gone wrong, because they would not know what data the server was expecting to receive.
    I hope I have not confused anyone too much. I know I've confused myself....

    Yes, that is the general model for all MMOGs these days - no data that can actually affect the game is safe if loaded from the client's computer. All character and world data is sent from server to client and stored in memory. Any information that is saved to the client's computer is for reference only and not used by the game engine to determine the results of actions/events etc.
    My program accesses the MMOG client's memory while the game is running, and takes the character information from there. It does not have direct access to the MMOG server, and does not attempt to modify the data or the memory. Instead, it just encrypts it and sends it to our server, where the information is loaded into a database.
    The security issue comes into play because our database is used for ranking purposes, and if someone were to hack my program, they could send invalid data to our servers and affect the rankings unfairly.
    I'm just trying to think of a way to prevent that from happening.

  • Client-Server - SOA.... Is it really a transition or a big development  ?

    Hi,
    In all sources related to SOA/ESA by SAP, it is said that, transitioning from Client-Server Arch(CSA) to SOA is the same as transitioning from Mainframe systems to Client-Server Arch.
    If we think about Mainframe and CSA, it is obvious that there had been big differences in that transition. Such as, the INTELLIGENT CLIENT concept had appeared to replace the DUMMY CLIENTS, so this had changed the way of IT Business. There would be a main application providing several functionalities(server) and other applications which want to use those functionalities (clients) would connect to the server using some functionalities on its own (that means a client appliction should also have some functionalities in order to at least connect to the server, so that made them different from the DUMMY clients of the mainframe era)
    Now, when I look at the differences between SOA and CSA, I cannot see that incompareble differences.Why ? Let me explain :
    - One of the most important differences between SOA and CSA is, SOA is vendor and platform independent, so that any application can call any applications functionality as long as they are using Web Services. That is true. But the question arises here : It is still the case that someone is calling some others' functionalities (services), so there is still a client/server mentality, isn't there and We will still be using several client/server programming languages in order to realize the main functionality of the web services but this will be transparent to the user and the integration. The main difference is, SOA is vendor and platform independent. But I don't think this can be commented as a missing feature of CSA. Because the aim of CSA was to make the clients more intelligent and not to make them vendor/platform independent. And also architectures like CORBA and DCOM have also tried to achieve that independency (even though they have restrictions compared to Web Services, one of the main reasons for this is using Web as a transport/communication protocol) but they are still treated as some extensions on top of CSA because they are using CSA beneath. But if we compare Mainframes and CSA, even though I haven't seen manframe ages, I think it is clear that CSA does not use any architectural functionality of Mainframes. They are completely different.. But is SOA and CSA completely different ?
    I agree with all reasons why today business needs sth more agile, more flexible and it is becoming clearer day by day that SOA and Web Services provides this environment, BUT, I still cannot make it clear, WHY it is accepted as a transition from CSA and why it is not treated as a big development over CSA while using the main features of it.
    Any comments will be appreciated.
    Regards
    Ahmet Engin Tekin

    Good point..Actually those are the things clearly known but it becomes a bit confusing to build clear sentences when it comes to declare the differences. Anyway, here are my additions :
    - Mainframes were centralized systems which had their own hardware architecture as well. All processes/applications were running on 1 central DB/system and everyone in the company had to use the same functionality and interface.
    - In time, as a result of business demand, people needed different functionalities/applications regarding different business needs. This could either be done by extending the higly-costed big mainframe systems/softwares OR a new approach had to be developed in order to solve those problems. At this point, (thanks to IBM,Macintosh and Xerox) PC and ethernet concepts had emerged. That was a completely different hardware architecture which allowed less costly systems and also distributing the process load and/or applications to different systems in one landscape (app servers, intelligent clients - 2 tier, 3- tier arch.). Thus, while those were happening on harware side, new communication and programming models/languages emerged on software side. As a result, people started using different applications on different systems according to their needs and thus an efficient solution had been provided to the business need (described above).
    To criticise, this was really a big transition. Not only software concepts but also hardware concepts are also changed drastically. Actually, it is not wrong if we say, developments on the hardware side, allowed changes on the software side
    - What happened next ? Companies started using so many different applications by different vendors with different business logic and programming models (thanks to CSA). But in times, this has emerged the biggest problem of the CSA era : Integration.
    We all know the rest. "Web Services" concept emerged with SOA as well. So that, the boundaries between the systems began to disappear.
    So, is this a transition ? Well, yes it is.. The point that made it confusing (at least for me) is that this time there is no hardware transition (yet) but only a transition in software side. But I still insist that the IT transition during Mainframe->CSA was like a revolution (forget what you've left behind) but from CSA to SOA; it is more likely to be an evolution (the next best thing)
    Anyone have more comments ?
    Regards,
    Ahmet

Maybe you are looking for

  • I have adobe photoshop éléments 6 registred whit a valid sérial number.

    I have adobe photoshop element 6 enregistred whith a valid sérial number. I have to reinstall it but the photoshop DVD is damaged Where I can download adobe photoshop 6 and apply my serial number?  (I find version 11 but no version 6)

  • Creating user accounts through ARD3 on client machines

    Hello. I am trying to create a secondary local admin account on some machines that are running ARD3/OS X 10.4.8. Right now, I am using only one machine as a test before attempting this on the several hundred machines I need to do this on. I used this

  • What happens with the message

    Hi there,  Could anyone point me in the right direction on where to get a documentation describing in DETAIL and step-by-step what is going on with the message inside BTS ? 1. Receive port is receiving a FLAT file or an XML... 2. What's next... 3....

  • Building from MPL sources

    Hi All, We need to customize some classes contained in rpc.swc. To avoid any potential licensing hassles, I decided to try building it from the MPL sources available for download at http://opensource.adobe.com/wiki/display/flexsdk/Download+Flex+3 So

  • Don't see the button for vanishing point - what gives?

    I just upgraded from Photoshop CS2 to Photoshop CS4, I also have a trial version of After Affects CS4 that I am using. I was trying to create a vanishing point in photoshop to send it to After Effects, and i know I'm supposed to use the little triang