Server/Client connection using an actionListener

Hey guys,
New to this board, so hopefully I can be of assistance :)
What I am currently working on is a networked Monopoly game. My part of the assignment is to create a simple game lobby (just GUI based, buttons, action listeners, etc) where players can create games and join games already created.
What I have is this. When a player clicks on the "Create Game" button, an anonomus inner action listener will detect the push and create a hosted game (Server side connection). When a player clicks on the newly created game, they will be a joined player (Client side connection).
The problem is this, keep in mind that I have created a very, very simple server/client chat to test this out. When a Socket is created for the clients to connect to upon the Create Game button push, my program essentially just hangs. Nothing happens at all.
Here are the 3 classes I used. I understand this is probably not the most efficient way to post, but this is the only way you can see what I exactly have. I took out all my GUI stuff to make it easier to follow (if you want me to post full classes I can):
Thanks for all the help!
- Ry
//package Mackopoly;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.BorderLayout;
import java.io.EOFException;
import java.io.IOException;
import java.net.ServerSocket;
import java.io.EOFException;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.ServerSocket;
import java.net.Socket;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.JFrame;
public class gameList extends JFrame {
    MackPlayer tc1;
    MackPlayer tc2;
    MackPlayer tc3;
    HostPlayer ts1;
    HostPlayer ts2;
    HostPlayer ts3;
    private String temp = ""; //used to display chat area
    private int gameCounter = 0; //number of games created
    private boolean game1Started = false;
    private boolean game2Started = false;
    private boolean game3Started = false;
    public void start()
    //Sets up the screen
        enterField.addActionListener(
        new ActionListener()
            public void actionPerformed(ActionEvent ae)
                if (ae.getSource() == enterField)
                    temp = enterField.getText();
                    chatBox.append(temp + "\n");
                    enterField.setText("");
        createGame.addActionListener(
        new ActionListener()
            public void actionPerformed(ActionEvent ae)
                if (ae.getSource() == createGame)
                    gameCounter++;
                    if(gameCounter == 1)
                        //create a new host game on the server
                        //instanciate an object accordingly
                        game1.setText("Game " + gameCounter + "started!");
                        game1Started = true;
                              ts1 = new HostPlayer();
                        ts1.execute();
                    else if(gameCounter == 2)
                        game2.setText("Game " + gameCounter + "started!");
                        game2Started = true;
                              ts2 = new HostPlayer();
                        ts2.execute();
                    else if(gameCounter == 3)
                        game3.setText("Game " + gameCounter + "started!");
                        game3Started = true;
                              ts3 = new HostPlayer();
                         ts3.execute();
                    else
                        System.out.println("games full");
        joinGame1.addActionListener(
        new ActionListener()
            public void actionPerformed(ActionEvent ae)
                if (ae.getSource() == joinGame1)
                    if(game1Started == false)
                        JOptionPane.showMessageDialog(null,"Start a game!");
                    if(game1Started == true)
                        JOptionPane.showMessageDialog(null,"Joined!");
                        tc1 = new MackPlayer("Game 1");
                        tc1.startClient();
        joinGame2.addActionListener(
        new ActionListener()
            public void actionPerformed(ActionEvent ae)
                if (ae.getSource() == joinGame2)
                    if(game2Started == false)
                        JOptionPane.showMessageDialog(null,"Start a game!");
                    if(game2Started == true)
                         JOptionPane.showMessageDialog(null,"Joined!");
                        tc2 = new MackPlayer("Game 2");
                        tc2.startClient();
        joinGame3.addActionListener(
        new ActionListener()
            public void actionPerformed(ActionEvent ae)
                if (ae.getSource() == joinGame3)
                    if(game3Started == false)
                        JOptionPane.showMessageDialog(null,"Start a game!");
                    if(game3Started == true)
                         JOptionPane.showMessageDialog(null,"Joined!");
                        tc3 = new MackPlayer("Game 3");
                        tc3.startClient();
    }//End start method
}//End of my class
import java.awt.*;
import java.awt.event.*;
import java.net.Socket;
import java.net.InetAddress;
import java.io.IOException;
import javax.swing.*;
import java.util.Formatter;
import java.util.Scanner;
import java.util.concurrent.Executors;
import java.util.concurrent.ExecutorService;
//Imports necessary packages
public class MackPlayer extends JFrame implements Runnable
//Client class
     private JTextField idField;
     private JTextArea displayArea;
     private JTextField guessArea;
     private JPanel panel2;
     private Socket connection;
     private Scanner input;
     private Formatter output;
     private String Host;
     private String myMark;
     private boolean myTurn;
     private final String X_MARK = "1";
     private final String O_MARK = "2";
     public MackPlayer(String host)
          Host = host;
          displayArea = new JTextArea(10,30);
          displayArea.setEditable(false);
          add(new JScrollPane(displayArea), BorderLayout.SOUTH);
          //Creates the message area
          idField = new JTextField();
          idField.setEditable(false);
          add(idField, BorderLayout.NORTH);
          //Creates the name field
          guessArea = new JTextField(10);
          guessArea.setEditable(false);
          add(new JScrollPane(guessArea), BorderLayout.CENTER);
          //Creates the guess area
          panel2 = new JPanel();
          panel2.add(guessArea, BorderLayout.CENTER);
          add(panel2, BorderLayout.CENTER);
          setSize(350, 275);
          setVisible(true);
          TextHandler tHandler = new TextHandler();
          idField.addActionListener(tHandler);
          guessArea.addActionListener(tHandler);
          //Adds the area's to the handler
          startClient();
     public void startClient()
     //Gets connection and starts thread
          try
               connection = new Socket(InetAddress.getByName(Host), 12345);
               input = new Scanner(connection.getInputStream());
               output = new Formatter(connection.getOutputStream());
          catch(IOException e)
               e.printStackTrace();
          ExecutorService worker = Executors.newFixedThreadPool(1);
          worker.execute(this);
     public void run()
          myMark = input.nextLine();
          SwingUtilities.invokeLater(
          new Runnable()
               public void run()
                    idField.setText("Enter name here");
                    guessArea.setText("Enter guess");
                    //Default text
          );//end call
          myTurn = (myMark.equals(X_MARK));
          while(true)
               if(input.hasNextLine())
                    processMessage(input.nextLine());
     private void processMessage(String message)
     //Handles all possible messages from the server
          if(message.equals("Guess too low."))
               displayMessage("Guess too low\n");
          else if(message.equals("Guess too high."))
               displayMessage("Guess too high\n");
          else if(message.equals("You Win!"))
               displayMessage("You Win!\n");
          else if(message.equals("Other player connected.  Your turn."))
               displayMessage("Other player connected.  Your turn\n");
               guessArea.setEditable(true);
          else if(message.equals("Name1"))
               displayMessage("Enter your name.\n");
               idField.setEditable(true);
          else if(message.equals("Name2"))
               displayMessage("Enter your name.\n");
               idField.setEditable(true);
          else if(message.equals("Player 2 has entered name"))
               displayMessage("Player 2 has entered name.  Your turn\n");
               guessArea.setEditable(true);
          else if(message.equals("Invalid guess, try again"))
               displayMessage(message + "\n");
               myTurn = true;
               guessArea.setEditable(true);
          else if(message.equals("Opponent guessed"))
               int sw = input.nextInt();
               displayMessage("Opponent guessed " + sw);
               sendGuess(sw);
               displayMessage("\nOpponent moved.  Your turn.\n");
               guessArea.setEditable(true);
          else if(message.equals("Opponent guessed and won"))
               int sw = input.nextInt();
               displayMessage("Opponent guessed and won with number " + sw);
               sendGuess(sw);
               guessArea.setEditable(false);
          else
               displayMessage(message + "\n");
     private void displayMessage(final String messageToDisplay)
          SwingUtilities.invokeLater(
          new Runnable()
               public void run()
                    displayArea.append(messageToDisplay);
     public void sendGuess(int guess)
          if(myTurn)
               output.format("%d\n", guess);
               output.flush();
     private class TextHandler implements ActionListener
     //Handles the fields
          public void actionPerformed(ActionEvent event)
               if(event.getSource() == idField)
                    idField.setEditable(false);
                    output.format("%s\n", idField.getText());
                    output.flush();
                    myTurn = false;
                    //Sends the name to the server
                    //Sets text to the name and sets it uneditable and sets turn to false
               if(event.getSource() == guessArea)
                    guessArea.setEditable(false);
                    output.format("%s\n", guessArea.getText());
                    output.flush();
                    guessArea.setText("");
                    myTurn = false;
                    //Send the guess to the server
                    //Clears the past guess from the screen
import java.awt.BorderLayout;
import java.net.ServerSocket;
import java.net.Socket;
import java.io.IOException;
import java.util.*;
import javax.swing.*;
import java.util.concurrent.*;
import java.util.concurrent.locks.*;
//Imports necessary packages
public class HostPlayer extends JFrame
//Server class
     private JTextArea outputArea;
     private Player[] players;
     private ServerSocket server;
     private int currentPlayer;
     private final static int PLAYER_1 = 0;
     private final static int PLAYER_2 = 1;
     private final static String[] MARKS = { "1", "2"};
     private ExecutorService runGame;
     private Lock gameLock;
     private Condition otherPlayerConnected;
     private Condition otherPlayerTurn;
     private Random generator = new Random();
     private int randomNumber;
     private String p1Name, p2Name;
     //Variables
     public HostPlayer()
          super("Guessing game");
          //Title of server window
          runGame = Executors.newFixedThreadPool(2);
          //Hanldes up to two clients
          gameLock = new ReentrantLock();
          //The lock
          otherPlayerConnected = gameLock.newCondition();
          otherPlayerTurn = gameLock.newCondition();
          //The condition variables
          players = new Player[2];
          currentPlayer = PLAYER_1;
          //The players
          try
               server = new ServerSocket(12345, 2);
          catch(IOException e)
               e.printStackTrace();
               System.exit(1);     
          //Establishes server
          randomNumber = generator.nextInt(10);
          //The number to be guessed 0-10
          outputArea = new JTextArea();
          add(outputArea, BorderLayout.CENTER);
          outputArea.setText("Server awaiting connections \n");
          //The output area
          displayMessage("The number is " + randomNumber + " \n");
          //Prints out what the number is
          setSize(300, 300);
          setVisible(true);
          //Sets the size of the server window
     public void execute()
          for(int i = 0; i < players.length; i++)
               try     
                    players[i] = new Player(server.accept(), i);
                    runGame.execute(players);
                    //Runs the threads to handle clients
               catch(IOException e)
                    e.printStackTrace();
                    System.exit(1);
          gameLock.lock();
          try
               players[PLAYER_1].setSuspended(false);
               otherPlayerConnected.signal();
          finally
               gameLock.unlock();
     private void displayMessage(final String messageToDisplay)
     //Function that displays messages
          //Class + method that can update the GUI for threads
          SwingUtilities.invokeLater(
          new Runnable()
               public void run()
                    outputArea.append(messageToDisplay);
     public boolean validateAndMove(int guess, int player)
     //Function that determines what the output should be based on the guess
          while(player != currentPlayer)
          //The player can only guess if it is his turn
               gameLock.lock();
               try
                    otherPlayerTurn.await();
               catch(InterruptedException e)
                    e.printStackTrace();
               finally
                    gameLock.unlock();
          if(correctRange(guess))
          //If the guess is a valid guess
               currentPlayer = (currentPlayer + 1) % 2;
               //Switches player turn
               players[currentPlayer].otherPlayerGuessed(guess);
               gameLock.lock();
               try
                    otherPlayerTurn.signal();
                    //Signals other player
               finally
                    gameLock.unlock();
               return true;
          else
               return false;
     public boolean correctRange(int guess)
     //Tests for a valid guess between 0-10
          if(guess >= 0 && guess <= 10)
               return true;
          else
               return false;
     private class Player implements Runnable
     //Player class
          private Socket connection;
          private Scanner input;
          private Formatter output;
          private int playerNumber;
          private String mark;
          private boolean suspended = true;
          private boolean game = true;
          public Player(Socket socket, int number)
               playerNumber = number;
               mark = MARKS[playerNumber];
               connection = socket;
               try
               //Tries to get the data streams
                    input = new Scanner(connection.getInputStream());
                    output = new Formatter(connection.getOutputStream());
               catch(IOException e)
                    e.printStackTrace();
                    System.exit(1);
          public void otherPlayerGuessed(int guess)
          //Function that detemines whether the guess is too high/low or correct
               if(guess == randomNumber)
                    output.format("Opponent guessed and won\n");
                    output.format("%d\n", guess);
                    output.flush();
               else
                    output.format("Opponent guessed\n");
                    output.format("%d\n", guess);
                    output.flush();
          public void run()
          //The start of the threads, at the beginning messages go back and forth to set up the connection
          //and player names
               try
                    displayMessage("Player " + mark + "connected \n");
                    output.format("%s\n", mark);
                    output.flush();
                    //Sends the message that the player has connected
                    if(playerNumber == PLAYER_1)
                         output.format("%s\n%s", "Player 1 connected ", "Waiting for another player\n");
                         output.flush();
                         gameLock.lock();
                         try
                              while(suspended)
                                   otherPlayerConnected.await();
                                   //Waits for player 2
                         catch(InterruptedException e)
                              e.printStackTrace();
                         finally
                              gameLock.unlock();
                         output.format("Name1\n");
                         output.flush();     
                         p1Name = input.nextLine();
                         displayMessage("Player 1 = " + p1Name + "\n");
                         //Sends a message to enter the name and puts the received name
                         //in the variable p1Name
                         output.format("Other player connected. Your turn.\n");
                         output.flush();
                         //Starts the game when the other player has connected
                         //A lot of the turn base is done with message handling
                         //on the client side     
                    else
                         output.format("Name2\n");
                         output.flush();
                         p2Name = input.nextLine();
                         displayMessage("Player 2 = " + p2Name + "\n");
                         output.format("Player 2 connected. Please wait.\n");
                         output.flush();
                         //Sets up player 2's name and turn
                    while(game)
                    //while the game is not over
                         int guess = 0;
                         if(input.hasNext())
                              guess = input.nextInt();
                         }//Gets next input
                         if(validateAndMove(guess, playerNumber))
                         //Sends the correct output based on the guess
                              if(guess < randomNumber)
                                   if(playerNumber == 0)
                                        displayMessage(" \n"+p1Name+ " guess: " + guess);
                                   else
                                        displayMessage(" \n" p2Name " guess: " + guess);
                                   output.format("Guess too low.\n");
                                   output.flush();
                              else if(guess > randomNumber)
                                   if(playerNumber == 0)
                                        displayMessage(" \n"+p1Name+ " guess: " + guess);
                                   else
                                        displayMessage(" \n" p2Name " guess: " + guess);
                                   output.format("Guess too high.\n");
                                   output.flush();
                              else
                                   if(playerNumber == 0)
                                        displayMessage(" \n"+p1Name+ " guess: " + guess);
                                   else
                                        displayMessage(" \n" p2Name " guess: " + guess);
                                   output.format("You Win!\n");
                                   output.flush();
                                   game = false;
                                   //Ends game
                         else
                              output.format("Invalid guess, try again\n");
                              output.flush();
               finally
                    try
                         connection.close();
                    catch(IOException e)
                         e.printStackTrace();
                         System.exit(1);
          }//End run
          public void setSuspended(boolean status)
               suspended = status;
     }//End player class
}//End Server class
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Thanks for the response
I think I understand what you are saying, I just want to make sure I get it fully. I need to create a separate thread that runs just my connection process to make sure that the processes actually occur? If so, how would I go about doing this?
Thanks again

Similar Messages

  • Windows Media Player no sound while playing a avi file in server and client connection using TCP/IP connection

    Hello there
    I have a problem with my windows media player while using server and client connection by using TCP/IP connection. So when I play a video using Windows Media Player in LabVIew there isn't any sound come out but when I'm playing a video by a Windows Media Player only the sound will come out. Can you help me solve this problem?
    I also upload the vi as the reference.
    The username for the client is ihsanhaikalz and the password is ganteng
    Thanks
    Attachments:
    Client Remote.vi ‏746 KB
    Server Remote.vi ‏1433 KB

    Hi ican,
    I was looking at your VI's but I cannot seem to pinpoint exactly where you are using Windows Media Player.  In order to more quickly assist you, could you please recreate this issue more concisely in a smaller set of VIs.  Also, were you able to get sound when you did not use the TCP/IP connection and simply played the files in LabVIEW?
    I noticed in a few places that you were using the Play Sound File.VI from the Graphics and Sounds palette.  Is that what you are refering to?  I noticed there that the file path that you have designated for the song is simply the song title.  Instead, this should be a path to where the song is located on your computer.
    Also, if you are planning on using Windows Media Player, have you considered using the ActiveX commands for Windows Media Player?  Here are a few examples if you are unfamiliar with this functionality.
    Example 1 and Example 2.
    I hope this helps!
    Kim W.
    Applications Engineer
    National Instruments

  • AP server client connection on SoH with System Replication

    Hi Experts
    I'm using Business Suite on HANA with  System Replication for HA purpose.
    As client access from ABAP server to HANA DB, I use DNS redirection.
    When I takeover to secondary system & after DNS redirection, the working process of user client (SAPGUI)  remains for a while until rdisp/max_wprun_time's limit.
    (means it not automatically restart process.)
    After creating new session from SAPGUI, it works correctly.
    Is this normal procedure?
    If it automatically re-connect with new DB connection, it would be useful.
    BR
    Yoh

    Thanks for the response
    I think I understand what you are saying, I just want to make sure I get it fully. I need to create a separate thread that runs just my connection process to make sure that the processes actually occur? If so, how would I go about doing this?
    Thanks again

  • Client connection using UNIX Domain Socket

    Hello all,
    I am getting the following error when I try to connect from a 32-bit TimesTen client to the 64-bit TimesTen data manager via UNIX domain socket.
    NOTE: I can make SHM connections from 32-bit client to 64-bit server though.
    # ttisqlcs test_uds
    Copyright (c) 1996-2007, Oracle. All rights reserved.
    Type ? or "help" for help, type "exit" to quit ttIsql.
    All commands must end with a semicolon character.
    connect "DSN=test_uds";
    08001: Unable to connect to data source (DSN: test_uds; Network Address: ttLocalHost; Port Number: 18003). Please refer to TimesTen Server log to see if connection over UNIX domain socket is allowed at this point in time
    The command failed.
    Done.
    Both 32-bit client and 64-bit server processes run on the same box. I do not see any errors in the user or server log files.
    Entry in sys.ttconnect.ini file
    [ttLocalHost-tt_704_dev]
    Description=TimesTen Server
    Network_Address=ttLocalHost
    TCP_PORT=18003
    Entry in sys.odbc.ini file
    [test_uds]
    Driver=/ttsoft/TimesTen32/TimesTen/tt70_32/lib/libttclient.so
    TTC_SERVER=ttLocalHost-tt_704_dev
    TTC_SERVER_DSN=test
    Thanks,
    Senthil.

    Could this be bug 4950822? This was documented in the 6.0.3 Release Notes "Known Limitations" section:
    "On Unix, when using ttlocalhost, a client of one TimesTen instance cannot connect with a server of another TimesTen instance. The workaround is to use ttShmHost (shared memory IPC) or localhost (127.0.0.1)."
    The error message received matches the one you're seeing.

  • Oracle server - client connection question

    This is my problem:
    Server A : oracle server (behind the firewall)
    Server B: the bridge server
    Server C: my application is on who need to connect to the database on A
    C can not connect to A directly. But it can connect to B. What are my options? If I install an oracle client on B, then can I connect to the client who will connect to the db server on A? Do I need to install a client on C as well? does it work?
    Thanks,
    Chau

    user626162 wrote:
    So I need to install the oracle client on C and the Oracle Connection Manager on server B? Would you point me to the document on how to do this?Correct. A good place to start is probably the [Configuring and Administering Oracle Connection Manager|http://download.oracle.com/docs/cd/B19306_01/network.102/b14212/cman.htm#NETAG011] chapter in the Net Services Administrator's Guide.
    Justin

  • Server / Client connection

    Hi guys i want to know that what is the process of client server connect
    i install database 10g in server version (10.2.0.1.0) and i also download same client version my tns names.ora file is
    +# tnsnames.ora Network Configuration File: D:\oracle\product\10.2.0\db_3\network\admin\tnsnames.ora+
    +# Generated by Oracle configuration tools.+
    LIVE =
    +(DESCRIPTION =+
    +(ADDRESS_LIST =+
    +(ADDRESS = (PROTOCOL = TCP)(HOST = COMPUTER1)(PORT = 1521))+
    +)+
    +(CONNECT_DATA =+
    +(SERVICE_NAME = live.ss64.com)+
    +)+
    +)+
    So how can i connect with client if i install same version of client in client system ?
    What is tns_admin role in client system?
    What is listneer role in client system?
    Please send some detail
    Regards
    Shahzaib ismail

    I would recommend you read thru the excellent documentation for an understanding of these concepts - http://download.oracle.com/docs/cd/B19306_01/server.102/b14220/dist_pro.htm#i4059
    HTH
    Srini

  • RTP Server/ Client Program using JMF Library

    Hi folks,
    I am trying to send A/V data from Camcorder(SONY DCR-PC115) to PC(Red Hat Linux 7.3 kernal version 2-18.3), and then send that data to clinet programm via a network ( i.e. A/V data should be delivered by network using RTP/RTCP Protocol).
    I guess I need to make RTP Server and RTP Client program, and using JMF library in order to send data with RTP Protocol. Isn't it?
    So what I want here is Do any body have idea/experiance in making RTP Clinet /Server program using JMF library then pls let me know
    my e-mail id is [email protected], [email protected]
    Many thanks
    looking forward to hear from you soon
    Regards
    Madhu Chundu

    Hi,
    I'm also working on the same type of problem, so if anyone has already worked or have an idea of how it works or does, please mail me the details to my mail-id: [email protected]
    Thanks In Advance,
    Rajanikanth Joshi

  • SM59 and a HTTP Client Connection Using SSL

    All,
    I'm running an ECC 6.0 (EHP 5) system.  Our ECC System is a dual stack system.  We've recently enabled SSL on the ECC's java stack.  The SSL Server Certificate has been signed by my organization's internal CA.  All of our desktops recognize this CA.  I'm pretty sure SM/59/our ABAP system does not.
    After enabling HTTPS on the Java Stack (TCP port 5XX01) we disabled the HTTP service (5XX00) per our security overlords mandate.
    The only application we have running on the Java Stack is Adobe Document Services.  The setup guide for ADS is located here.
    As you can see, ADS involves a HTTP Connection in SM59.  How do I configure this HTTP connection in SM59 over SSL (HTTPS).
    Key considerations:
    1. I've not imported our Enterprises' Root CA into the Trusted CAs for AS ABAP for the main reason that I do not know how to.  How do I do this?

    Presently I have gone to the "Logon & Security" tab of SM59.  Under "Security Options" I have set SSL to "Active".  SSL Certificate is set to ANONYM SSL (Anonymous).  On the "Technical Settings" tab I have updated the port to point to the HTTPS port.
    When I test the RFC, as presently configured, the error is "ICM_HTTP_CONNECTION_FAILED", with no additional details or long text.

  • Need an example of server / client program with swing interface

    Hi!
    After a lot of trying i still haven't managed to create a server client program using swing components ...
    can someone write a mini application to demonstrate how this can be done?
    i would like to have a frame with a button a texField for input and a textAread for the output
    What i have in mind is the following ..
    say im the server
    i write something in the textField and then i press the button
    then the information written in the textFiled is passed to the client who shows it in his textArea
    The same thing goes on with the client (he can write something in his own textField and when he presses the button the info is passed at the
    server who puts it in his textArea) and vice versa.
    i have written many classes that trying unsuccessfully to do that ... below i show my last attempt ...
    I would appreciate if you could write a small application which it could to this.
    The whole idea is to create a turn based game ( i have implemented the game engine and graphics and i try to add the internet function)
    Here is the code ...( i would appreciate if you write a new code instead of trying to correct mine ( which i think it's impossible) in order to use it as a general example)
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    @SuppressWarnings("serial")
    *  In order to have a more gereral program instead of passing strings between the server
    *  and the client a pass an MyObjext object.  The MyObject class has an integer and a String
    *  (which is always the same) field . At the textField i write an integer number and i
    *  make a new MyObject which i want to pass to the server or the client and vice versa.
    *  The textArea shows the integer value of the MyObject which was passed from the server /client
    public class MyUserInterface extends JFrame {
         MyObject returnObject;
         JTextField myTextField;
         JTextArea te ;
         ClientGame cg;
         ServerGame sg;
          * used to determine if the current instance is running as a client or host
         boolean isHost;
         //The constructor of the client
         public MyUserInterface(ClientGame cg){
              this("Client");
              this.cg = cg;
              isHost = false;
         //The constructor of the server
         public MyUserInterface(ServerGame sg){
              this("Server");
              this.sg = sg;
              isHost = true;
         //The general constructor used both by client and server ..
         // it initializes the GUi components and add an actionListenr to the button
         public MyUserInterface(String str) {
              super(str);
              myTextField = new JTextField(2);
              te = new JTextArea();
              te.setPreferredSize(new Dimension(100,100));
              JButton okButton = new JButton("Ok");
              okButton.addActionListener(new ActionListener() {
                   @Override
                   public void actionPerformed(ActionEvent e) {
                        try{
                             int a = Integer.parseInt(MyUserInterface.this.myTextField.getText());
                             System.out.println(a);   //used to control the flow of the program
                                  MyUserInterface.this.returnObject = new MyObject(a);
                             //sends the data
                             sendData();
                             //waiting for response...
                             getData();
                             catch(Exception ex){System.out.println("Error in the UI action command" +
                                                                ex.printStackTrace();}
              JPanel panel =  new JPanel(new FlowLayout());
              panel.add(okButton);
              panel.add(myTextField);
              panel.add(te);
              setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              getContentPane().add(panel);
              pack();
              setVisible(true);
         protected MyObject getReturnObject() {
              return returnObject;
         public void sendData(){
              new Thread(new Runnable() {
                   @Override
                   public void run() { 
                        if (!isHost)cg.sentData(returnObject);    //using the Servers out and in methods
                        else sg.sentData(returnObject);                    //using the Clients out and in methods
                        System.out.println("data sending");
         public MyObject getData(){
              MyObject obj;
              System.out.println("Retrieveing Data");
              if (!isHost)obj = (MyObject)cg.getData();
              else obj = (MyObject)sg.getData();
              System.out.println(" data retrieved  = "+ obj.getInt());  //just to control how the code flows
              te.setText(obj.getInt()+"");       
              return obj;
         public static void main(String[] args) {
              *Initiating the Server
              new Thread(new Runnable() {
                   @Override
                   public void run() {
                        ServerGame sg = new ServerGame();
                        new MyUserInterface(sg);
              }).start();     
               * Initiating the Client
              new Thread(new Runnable() {
                   @Override
                   public void run() {
                        ClientGame cg = new ClientGame("192.168.178.21");   //<----in case you run my code
                                                                          //..don't forget to change to your
                        new MyUserInterface(cg);                              //ip
              }).start();
    import java.io.*;
    import java.net.*;
    public class ClientGame {
         String ipAddress;
         Socket clientSocket = null;
        ObjectOutputStream out = null;
        ObjectInputStream in = null;
         public ClientGame(String ipAddress) {
              this.ipAddress = ipAddress;
              try {
                   System.out.println("Connecting To Host");
                 clientSocket = new Socket(InetAddress.getByName(ipAddress),4444);
                System.out.println("Host Found ...Io initializaton");
                out = new ObjectOutputStream(clientSocket.getOutputStream());
                in = new ObjectInputStream(clientSocket.getInputStream());
            } catch (UnknownHostException e) {
                System.err.println("Don't know about host: taranis.");
                System.exit(1);
            } catch (IOException e) {
                System.err.println("Couldn't get I/O for the connection to: taranis.");
                System.exit(1);
         public Object getData(){
              Object fromServer = null ;
              do{
                 try {
                      fromServer = in.readObject();
                 catch(ClassNotFoundException ex){}
                  catch(IOException e){}
              }while(fromServer==null);
              return fromServer;        
         public void sentData(final Object obj){
              new Thread(new Runnable() {
                   @Override
                   public void run() {
                        try{
                             out.writeObject(obj);
                        catch(IOException e){}
              }).start();
         public void terminateConnection(){
              try{
                   out.close();
                   in.close();
                   clientSocket.close();
              catch (IOException e){}
    public class ServerGame {
         ServerSocket serverSocket;
         Socket clientSocket;
         ObjectOutputStream out = null;
        ObjectInputStream in = null;
         public ServerGame() {
              try{
                   serverSocket = new ServerSocket(4444);
                   clientSocket = serverSocket.accept();
                   out =  new ObjectOutputStream(clientSocket.getOutputStream());
                in = new ObjectInputStream(clientSocket.getInputStream());
              catch(IOException e){System.out.println("IOException in ServerGame");}
         public Object getData(){
              Object fromClient = null ;
              do{
                 try {
                      fromClient = in.readObject();
                 catch(ClassNotFoundException ex){}
                  catch(IOException e){}
              }while(fromClient==null);
             return fromClient;        
         public void sentData(final Object obj){
              new Thread(new Runnable() {
                   @Override
                   public void run() {
                        try{
                   out.writeObject(obj);
              catch(IOException e){}
              }).start();
         public void terminateConnection(){
              try{
                   out.close();
                   in.close();
                   clientSocket.close();
                   serverSocket.close();
              catch (IOException e){}
         public static void main(String[] args) {
              new ServerGame();
    import java.io.Serializable;
    * this is a test object
    * it has a String field and a value
    *  The string is always the same but the integer value is defined in the constructor
    public class MyObject implements Serializable{
         private static final long serialVersionUID = 1L;
         String str;
         int myInt;
         MyObject(int a){
              str = "A String";
              myInt = a;
         public int getInt(){
              return myInt;
    }

    Pitelk wrote:
    I believe that a good code example can teach you things ;that you would need many days of searching; in no timeSo lets write one small example.. Ill help a little, but you do most of the work.
    jverd approach is deffenetly the way to go.
    jverd wrote:
    * Write a very small, simple Swing program with an input area, an output area, and a button. When you click the button, what's in the input area gets copied over to the output area.This part is partially done.
    * Write a very small, simple client/server program without Swing. It should just send a couple of hardcoded messages back and forth.And this part is for you(Pitelk) to continue on. I cannot say that this is the best way. or that its good in any way. I do however like to write my client/server programs like this. And perhaps, and hopefully, Ill learn something new from this as well.
    This is how far I got in about 10-20min..
    package client;
    * To be added;
    * A connect method. That connects the client to the server and
    * opens up both the receive and transmit streams. After doing that
    * the an instance of the ServerListener class should be made.
    * Also an disconnect method could be usable. But thats a later part.
    public class TestClass1 {
    package utils;
    import java.io.ObjectInputStream;
    import client.TestClass1;
    * This class is meant to be listening to all responses given from
    * the server to the client. After a have received data from the
    * server. It should be forwarded to the client, in this case
    * TestClass1.
    public class ServerListener implements Runnable {
         public ServerListener(ObjectInputStream in, TestClass1 tc) {
         @Override
         public void run() {
              while(true) {
    package server;
    import java.io.ObjectOutputStream;
    import java.net.Socket;
    import java.util.ArrayList;
    import java.util.List;
    * This class should handle all data sent to the server from the clients.
    class Server implements Runnable {
         private static List<ObjectOutputStream> outStreams = new ArrayList<ObjectOutputStream>();
         private Socket client = null;
         public Server(Socket client) {
              this.client = client;
         @Override
         public void run() {
              while(true) {
    * The meaning of this class is to listen for clients trying to connect
    * to the server. Once connection is achieved a new thread for that client
    * should be made to listen for data sent by the client to the server.
    public class ChatServer implements Runnable {
         @Override
         public void run() {
              while(true) {
    package utils;
    import java.io.Serializable;
    @SuppressWarnings("serial")
    public class MyObject implements Serializable {
         private String mssg;
         private String clientID;
         private String clientName;
         public MyObject(String mssg, String clientID, String clientName) {
              this.mssg = mssg;
              this.clientID = clientID;
              this.clientName = clientName;
         //Generate getters and setters..
    }Continue on this, and when you get into problems etc post them. Also show with a small regular basis how far you have gotten with each class or it might be seen as you have lost intresst and then this thread is dead.
    EDIT: I should probably also say that Im not more than a java novice, at the verry most. So I cannot guarantee that I alone will be able to solve all the problems that might occure during this. But Im gonna try and help with the future problems that may(most likely will) occure atleast(Trying to reserve my self incase of misserable failiure from me in this attempt).
    Edited by: prigas on Jul 7, 2008 1:47 AM

  • Remote access VPN clients connected to Internet from VPN

    Greetings,
    I need to let remote VPN clients to connect to Internet from the same ASA VPN server
    " client connects to ASA through VPN tunnel from outside interface then access Internet from the same ASA from outside interface again
    thanks

    you'll need to configure 'same-security-traffic permit intra-interface' on the ASA .
    Also, need to setup the corresponding nat statements for your clients pool range.
    i.e.
    global (outside) 1 interface
    nat (outside) 1 access-list anyconnectacl
    where anyconnectacl is the pool for your clients:
    access-list anyconnectacl permit ip 172.16.1.0 255.255.255.0 any

  • AIR-SAP1602I-N-K9 client connectivity issue

    Hi All,
    Using AIR-SAP1602I-N-K9 Autonomous mode and clients connect using the WEP authentication. the problem is any new laptops were unable to associate with the AP.
    I have ran dot11 debug for client.
    %DOT11-6-ASSOC: Interface Dot11Radio0, Station  7018.8bf7.6814 Associated KEY_MGMT[NONE]
    %DOT11-4-ENCRYPT_MISMATCH: Possible encryption key mismatch between interface Dot11Radio0 and station 7018.8bf7.6814
     %DOT11-6-DISASSOC: Interface Dot11Radio0, Deauthenticating Station 7018.8bf7.6814 Reason: Sending station has left the BSS
    but unable find the cause. any suggestion to find the cause.
    current :
    flash:/ap1g2-k9w7-mx.152-2.JB/ap1g2-k9w7-mx.152-2.JB
    Regards,
    Channa

    Using AIR-SAP1602I-N-K9 Autonomous mode and clients connect using the WEP authentication
    WEP is no longer treated as "SECURE". So move away from using WEP. Use WPA2-PSK instead.
    Here is a very basic sample configuration with single SSID
    conf t
    hostname <AP_HOSTNAME>
    dot11 ssid <SSID_NAME>
    authentication open
    authentication key-management wpa version 2
    guest-mode
    wpa-psk ascii <SSID_PASSWORD>
    interface Dot11Radio0
    encryption mode ciphers aes-ccm
    ssid <SSID_NAME>
    no shutdown
    interface Dot11Radio1
    encryption mode ciphers aes-ccm
    ssid <SSID_NAME>
    no shutdown
    interface BVI1
    ip address dhcp
    end
    write memory
    HTH
    Rasika
    **** Pls rate all useful responses ****

  • (Cisco Historical Reporting / HRC ) All available connections to database server are in use by other client machines. Please try again later and check the log file for error 5054

    Hi All,
    I am getting an error message "All available connections to database server are in use by other client machines. Please try again later and check the log file for error 5054"  when trying to log into HRC (This user has the reporting capabilities) . I checked the log files this is what i found out 
    The log file stated that there were ongoing connections of HRC with the CCX  (I am sure there isn't any active login to HRC)
    || When you tried to login the following error was being displayed because the maximum number of connections were reached for the server .  We can see that a total number of 5 connections have been configured . ||
    1: 6/20/2014 9:13:49 AM %CHC-LOG_SUBFAC-3-UNK:Current number of connections (5) from historical Clients/Scheduler to 'CRA_DATABASE' database exceeded the maximum number of possible connections (5).Check with your administrator about changing this limit on server (wfengine.properties), however this might impact server performance.
    || Below we can see all 5 connections being used up . ||
    2: 6/20/2014 9:13:49 AM %CHC-LOG_SUBFAC-3-UNK:[DB Connections From Clients (count=5)]|[(#1) 'username'='uccxhrc','hostname'='3SK5FS1.ucsfmedicalcenter.org']|[(#2) 'username'='uccxhrc','hostname'='PFS-HHXDGX1.ucsfmedicalcenter.org']|[(#3) 'username'='uccxhrc','hostname'='PFS-HHXDGX1.ucsfmedicalcenter.org']|[(#4) 'username'='uccxhrc','hostname'='PFS-HHXDGX1.ucsfmedicalcenter.org']|[(#5) 'username'='uccxhrc','hostname'='47BMMM1.ucsfmedicalcenter.org']
    || Once the maximum number of connection was reached it threw an error . ||
    3: 6/20/2014 9:13:49 AM %CHC-LOG_SUBFAC-3-UNK:Number of max connection to 'CRA_DATABASE' database was reached! Connection could not be established.
    4: 6/20/2014 9:13:49 AM %CHC-LOG_SUBFAC-3-UNK:Database connection to 'CRA_DATABASE' failed due to (All available connections to database server are in use by other client machines. Please try again later and check the log file for error 5054.)
    Current exact UCCX Version 9.0.2.11001-24
    Current CUCM Version 8.6.2.23900-10
    Business impact  Not Critical
    Exact error message  All available connections to database server are in use by other client machines. Please try again later and check the log file for error 5054
    What is the OS version of the PC you are running  and is it physical machine or virtual machine that is running the HRC client ..
    OS Version Windows 7 Home Premium  64 bit and it’s a physical machine.
    . The Max DB Connections for Report Client Sessions is set to 5 for each servers (There are two servers). The no of HR Sessions is set to 10.
    I wanted to know if there is a way to find the HRC sessions active now and terminate the one or more or all of that sessions from the server end ? 

    We have had this "PRX5" problem with Exchange 2013 since the RTM version.  We recently applied CU3, and it did not correct the problem.  We have seen this problem on every Exchange 2013 we manage.  They are all installations where all roles
    are installed on the same Windows server, and in our case, they are all Windows virtual machines using Windows 2012 Hyper-V.
    We have tried all the "this fixed it for me" solutions regarding DNS, network cards, host file entries and so forth.  None of those "solutions" made any difference whatsoever.  The occurrence of the temporary error PRX5 seems totally random. 
    About 2 out of 20 incoming mail test by Microsoft Connectivity Analyzer fail with this PRX5 error.
    Most people don't ever notice the issue because remote mail servers retry the connection later.  However, telephone voice mail systems that forward voice message files to email, or other such applications such as your scanner, often don't retry and
    simply fail.  Our phone system actually disables all further attempts to send voice mail to a particular user if the PRX5 error is returned when the email is sent by the phone system.
    Is Microsoft totally oblivious to this problem?
    PRX5 is a serious issue that needs an Exchange team resolution, or at least an acknowledgement that the problem actually does exist and has negative consequences for proper mail flow.
    JSB

  • What privileges for the DB account used by client connect to server?

    Hello, After I installed the SBO server packages, I found that it must set DB account in the client side.
    I had tried 'sa' account, it works. but I thought we should not leave the super account in each client side.
    So I want to know what privileges should be assiged to the account in SQL Server?
    Or somewhere already have documents to say how to build up the client account.
    thanks.

    Hi,
    You may check: What privileges for the DB account used by client connect to server?
    Thanks,
    Gordon

  • How to make the client connect to the server at the command prompt?

    I found this code on IBM's website, it was a training session on servers and clients using java.
    The code compiles fine and the server seems to start up properly when I use java Server 5000. I think whats happening is the server is running and listening for a connection on port 5000.
    When I try to run the client I get the following error.
    Exception in thread "main" java.lang.NoSuchMethodError: main
    I see a start() method but no main. As far as I know, applications should all have main, it seems as if the person who wrote this kinda confused applets with application. Not that I would really know what happened.
    If you have time, could you tell me if there's an easy fix for this? I would love to have this client/server working if it isn't too much trouble. As I have looked all over the net for a free client/server applet that will actually let me see the java code and none of the free ones do allow getting to their source.
    Most of them allow you to customize them somewhat but also have built in advertising that can't be removed.
    This is the closest I have come to finding one that lets me look under the hood. But alas it doesn't work out of the box and I don't know what to do to fix it.
    Heres the code: Server:
    import java.io.*;
    import java.net.*;
    import java.util.*;
    public class Server
      // The ServerSocket we'll use for accepting new connections
      private ServerSocket ss;
      // A mapping from sockets to DataOutputStreams.  This will
      // help us avoid having to create a DataOutputStream each time
      // we want to write to a stream.
      private Hashtable outputStreams = new Hashtable();
      // Constructor and while-accept loop all in one.
      public Server( int port ) throws IOException {
        // All we have to do is listen
        listen( port );
      private void listen( int port ) throws IOException {
        // Create the ServerSocket
        ss = new ServerSocket( port );
        // Tell the world we're ready to go
        System.out.println( "Listening on "+ss );
        // Keep accepting connections forever
        while (true) {
          // Grab the next incoming connection
          Socket s = ss.accept();
          // Tell the world we've got it
          System.out.println( "Connection from "+s );
          // Create a DataOutputStream for writing data to the
          // other side
          DataOutputStream dout = new DataOutputStream( s.getOutputStream() );
          // Save this stream so we don't need to make it again
          outputStreams.put( s, dout );
          // Create a new thread for this connection, and then forget
          // about it
          new ServerThread( this, s );
      // Get an enumeration of all the OutputStreams, one for each client
      // connected to us
      Enumeration getOutputStreams() {
        return outputStreams.elements();
      // Send a message to all clients (utility routine)
      void sendToAll( String message ) {
        // We synchronize on this because another thread might be
        // calling removeConnection() and this would screw us up
        // as we tried to walk through the list
        synchronized( outputStreams ) {
          // For each client ...
          for (Enumeration e = getOutputStreams(); e.hasMoreElements(); ) {
            // ... get the output stream ...
            DataOutputStream dout = (DataOutputStream)e.nextElement();
            // ... and send the message
            try {
              dout.writeUTF( message );
            } catch( IOException ie ) { System.out.println( ie ); }
      // Remove a socket, and it's corresponding output stream, from our
      // list.  This is usually called by a connection thread that has
      // discovered that the connectin to the client is dead.
      void removeConnection( Socket s ) {
        // Synchronize so we don't mess up sendToAll() while it walks
        // down the list of all output streamsa
        synchronized( outputStreams ) {
          // Tell the world
          System.out.println( "Removing connection to "+s );
          // Remove it from our hashtable/list
          outputStreams.remove( s );
          // Make sure it's closed
          try {
            s.close();
          } catch( IOException ie ) {
            System.out.println( "Error closing "+s );
            ie.printStackTrace();
      // Main routine
      // Usage: java Server <port>
      static public void main( String args[] ) throws Exception {
        // Get the port # from the command line
        int port = Integer.parseInt( args[0] );
        // Create a Server object, which will automatically begin
        // accepting connections.
        new Server( port );
    }CLIENT:
    import java.io.*;
    import java.net.*;
    public class ServerThread extends Thread
      // The Server that spawned us
      private Server server;
      // The Socket connected to our client
      private Socket socket;
      // Constructor.
      public ServerThread( Server server, Socket socket ) {
        // Save the parameters
        this.server = server;
        this.socket = socket;
        // Start up the thread
        start();
      // This runs in a separate thread when start() is called in the
      // constructor.
      public void run() {
        try {
          // Create a DataInputStream for communication; the client
          // is using a DataOutputStream to write to us
          DataInputStream din = new DataInputStream( socket.getInputStream() );
          // Over and over, forever ...
          while (true) {
            // ... read the next message ...
            String message = din.readUTF();
            // ... tell the world ...
            System.out.println( "Sending "+message );
            // ... and have the server send it to all clients
            server.sendToAll( message );
        } catch( EOFException ie ) {
          // This doesn't need an error message
        } catch( IOException ie ) {
          // This does; tell the world!
          ie.printStackTrace();
        } finally {
          // The connection is closed for one reason or another,
          // so have the server dealing with it
          server.removeConnection( socket );
    }Thanks for your time.

    CLIENT:
    import java.applet.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import java.net.*;
    public class Client extends Panel implements Runnable
      // Components for the visual display of the chat windows
      private TextField tf = new TextField();
      private TextArea ta = new TextArea();
      // The socket connecting us to the server
      private Socket socket;
      // The streams we communicate to the server; these come
      // from the socket
      private DataOutputStream dout;
      private DataInputStream din;
      // Constructor
      public Client( String host, int port ) {
        // Set up the screen
        setLayout( new BorderLayout() );
        add( "North", tf );
        add( "Center", ta );
        // We want to receive messages when someone types a line
        // and hits return, using an anonymous class as
        // a callback
        tf.addActionListener( new ActionListener() {
          public void actionPerformed( ActionEvent e ) {
            processMessage( e.getActionCommand() );
        // Connect to the server
        try {
          // Initiate the connection
          socket = new Socket( host, port );
          // We got a connection!  Tell the world
          System.out.println( "connected to "+socket );
          // Let's grab the streams and create DataInput/Output streams
          // from them
          din = new DataInputStream( socket.getInputStream() );
          dout = new DataOutputStream( socket.getOutputStream() );
          // Start a background thread for receiving messages
          new Thread( this ).start();
        } catch( IOException ie ) { System.out.println( ie ); }
      // Gets called when the user types something
      private void processMessage( String message ) {
        try {
          // Send it to the server
          dout.writeUTF( message );
          // Clear out text input field
          tf.setText( "" );
        } catch( IOException ie ) { System.out.println( ie ); }
      // Background thread runs this: show messages from other window
      public void run() {
        try {
          // Receive messages one-by-one, forever
          while (true) {
            // Get the next message
            String message = din.readUTF();
            // Print it to our text window
            ta.append( message+"\n" );
        } catch( IOException ie ) { System.out.println( ie ); }
    import java.applet.*;
    import java.awt.*;
    import java.io.*;
    import java.net.*;
    public class ClientApplet extends Applet
      public void init() {
        String host = getParameter( "192.168.1.47" );
        int port = Integer.parseInt( getParameter( "5000" ) );
        setLayout( new BorderLayout() );
        add( "Center", new Client( host, port ) );
    }Sorry about that. Now when I run an html file with this applet I just get the x in the corner.
    Thanks for looking.

  • Java Chat (Server, Client Socket Connection)

    Assignment:
    The assignment is to deliver two source codes that can run a Server (1) and Clients (2) in order to create a simpel chat program. The server has to wait and check an IP (localhost) + Port, and the client has to connect to that port and create a socket connection. The only thing that should be done is create a new socket connection for each client... and when a client sends a message, the message should be delivered to all clients connected to the server.
    Problem...
    However I can read an edit Java, it's difficult for me to write it. I allready found many turturials about socket connections on the internet, and tried to edit those, but they don't really do what I want unless I really write new shit. Is there a way you guys can help me with this, or that you find a really good website that fits my question?

    According to me ,
    take string variable 'str'
    Take some class ,I think u already taken.....
    Scoket scoket = new Socket(IP,port);
    OutputStream out;
    IInputStream in;
    in = socket.getInputStream();
    out = socket.getOutputStream();
    If sends the msg then use
    out.writeObject(str);
    This line sends data to the other user
    msg resivce from client then use
    str = in.readInput();
    & this str set to the any objects out put .
    Such as TextField.setText(str);
    //Server.class
    import java.io.EOFException;
    import java.io.IOException;
    import java.io.ObjectInputStream;
    import java.io.ObjectOutputStream;
    import java.net.ServerSocket;
    import java.net.Socket;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.event.ActionListener;
    import javax.swing.*;
    public class Server extends JFrame
              private JTextField enterdField;
              private JTextArea displayArea;
              private ObjectOutputStream output;
              private ObjectInputStream input;
              private ServerSocket server;
              private Socket connection;
              private int counter=1;
              public Server()
                        super("Server");
                        enterdField = new JTextField();
                        enterdField.setEditable(false);
                        enterdField.addActionListener(
                             new ActionListener()
                                       public void actionPerformed(ActionEvent event)
                                                 sendData(event.getActionCommand());
                                                 //System.out.println(event.getActionCommand());
                                                 enterdField.setText("");
                   add(enterdField,BorderLayout.NORTH);
                   displayArea = new JTextArea();
                   add(new JScrollPane(displayArea),BorderLayout.CENTER);
                   setSize(300,150);
                   setVisible(true);
              public void runServer()
                        try
                                  server = new ServerSocket(12345,100);
                                  while(true)
                                            try
                                                      waitForConnection();
                                                      getStreams();
                                                      processConnection();
                                            catch(EOFException eofexception)
                                                      displayMessage("\nServer terminated connection");
                                            finally
                                                      closeConnection();
                                                      counter++;
                        catch(IOException ioException)
                                  ioException.printStackTrace();
              private void waitForConnection() throws IOException
                        displayMessage("Waiting for connection");
                        connection = server.accept();
                        //System.out.println(server.accept());
                        System.out.println(connection.getInetAddress());//Server Address and Hostname.
                        displayMessage("Connection"+counter +"received from :"+connection.getInetAddress().getHostName());
              private void getStreams() throws IOException
                        System.out.println("Start getStream");
                        output = new ObjectOutputStream(connection.getOutputStream());
                        output.flush();
                        input = new ObjectInputStream(connection.getInputStream());
                        displayMessage("\nGot I/O stream\n");
              private void processConnection() throws IOException //Read data from Client for Server.
                        String message="Connection sucessful To Client";
                        sendData(message);
                        int i=0;
                        setTextFieldEditable(true);
                        do
                                  try
                                            message =(String) input.readObject();//For Client
                                            System.out.println("Input from :"+message);//From Client
                                            displayMessage("\n" + message);
                                            System.out.println("\n" + i++);
                                  catch(ClassNotFoundException classnotfoundexception)
                                            displayMessage("\nUnknown object type recived");
                        while(!message.equals("CLIENT>>>TERMINATE"));
              private void closeConnection()
                        displayMessage("\nTeminating connection");
                        setTextFieldEditable(false);
                        try
                                  output.close();
                                  input.close();
                                  connection.close();
                        catch(IOException ioException)
                                  ioException.printStackTrace();
              private void sendData(String message)//Write data to the Client from the Server.
                        try
                                  output.writeObject("SERVER>>>"+message);//For Client side.
                                  System.out.println(message);
                                  output.flush();
                                  displayMessage("\nSERVER>>>"+message);//On server side.
                        catch(IOException ioException)
                                  displayMessage("\nError writing object");
              private void displayMessage(final String messageToDisplay)
                        SwingUtilities.invokeLater(
                             new Runnable()
                                  public void run()
                                            displayArea.append(messageToDisplay);
              private void setTextFieldEditable(final boolean editable)
                        SwingUtilities.invokeLater(
                             new Runnable()
                                  public void run()
                                            enterdField.setEditable(editable);
              public static void main(String q[])
                        Server app = new Server();
                        app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                        app.runServer();
    //Client.class
    import java.io.EOFException;
    import java.io.IOException;
    import java.io.ObjectInputStream;
    import java.io.ObjectOutputStream;
    import java.net.InetAddress;
    import java.net.Socket;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.event.ActionListener;
    import javax.swing.*;
    public class Client extends JFrame
         private JTextField enterField;
         private JTextArea displayArea;
         private ObjectOutputStream output;
         private ObjectInputStream input;
         private String message="";
         private String chatServer;
         private Socket client;
         public Client (String host)
                   super("Client");
                   chatServer=host;
                   enterField = new JTextField();
                   enterField.setEditable(false);
                   enterField.addActionListener(
                        new ActionListener()
                                  public void actionPerformed(ActionEvent event)
                                            sendData(event.getActionCommand());
                                            enterField.setText("");
                        add(enterField,BorderLayout.NORTH);
                        displayArea = new JTextArea();
                        add(new JScrollPane(displayArea),BorderLayout.CENTER);
                        setSize(300,150);
                        setVisible(true);
         public void runclient()
                   try
                             connectToServer();
                             getStreams();
                             processConnection();
                   catch(EOFException eofException)
                             displayMessage("\nClient treminated connection");
                   catch(IOException ioException)
                             ioException.printStackTrace();
                   finally
                             closeConnection();
         private void connectToServer() throws IOException
                   displayMessage("Attempting connection\n");
                   client = new Socket(InetAddress.getByName(chatServer),12345);
                   displayMessage("Connect to:"+client.getInetAddress().getHostName());
         private void getStreams() throws IOException
                   output = new ObjectOutputStream(client.getOutputStream());
                   output.flush();
                   input = new ObjectInputStream(client.getInputStream());
                   //Thread t = new Thread(this,"Thread");
                   //t.start();
                   displayMessage("\nGot I/O stream\n");
         private void processConnection( ) throws IOException
                   setTextFieldEditable(true);
                   do
                             try
                                       message=(String)input.readObject();
                                       displayMessage("\n"+message);
                             catch(ClassNotFoundException classnotfoundexception)
                                       displayMessage("\nUnknown object type received");
                   while(!message.equals("SERVER>>>TERMINATE"));
         private void closeConnection()
                   displayMessage("\n Closing connection");
                   setTextFieldEditable(false);
                   try
                             output.close();
                             input.close();
                             client.close();
                   catch(IOException ioException)
                             ioException.printStackTrace();
         private void sendData(String message)
                   try
                             output.writeObject("CLIENT>>>"+message);
                             //System.out.println(message);
                             output.flush();
                             displayMessage("\nCLIENT>>>"+message);
                   catch(IOException ioException)
                             displayArea.append("\n Error writing object");
         private void displayMessage(final String MessageToDisplay)
                   SwingUtilities.invokeLater(
                        new Runnable()
                                  public void run()
                                            displayArea.append(MessageToDisplay);
         private void setTextFieldEditable(final boolean editable)
                   SwingUtilities.invokeLater(
                        new Runnable()
                                  public void run()
                                            enterField.setEditable(editable);
         public static void main(String q[])
                   Client app;
                   if(q.length==0)
                             app = new Client("127.0.0.1");
                   else
                             app = new Client(q[0]);
                   app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                   app.runclient();
    Use this example .....
    Give me reply.My method is correct or not
    All the best

Maybe you are looking for

  • How do you change the dpi of a pdf?

    I'm really confused as to how to change my dpi to 300. I'm not even really sure how I can check what it is? Thanks!

  • How do I switch from a basic phone to a smart phone on the single line plan?

    I currently have a basic phone on a basic phone plan. My contract expired ages ago, so I'm just month to month at the moment. I want to upgrade my phone to an iPhone 5c, and my plan to the single line plan--unlimited talk and text, 1GB of data. Howev

  • Method which fills bol entity?

    hi Experts,                 I have created many interaction record which are linked to1 service ticket.I fetch the guid values of these interaction records,now i want to set a field in the interacton record for all tehse guids.Is there any method ava

  • How to make page chapters like wikipedia in Dreamweaver.

    Hi all, I'm a graphic design student currently producing my own portfolio website. It's a work in progress so I haven't published it unfortunately but will be in the next week. So I'll do my best to describe the feaure I would lie to add to it. It's

  • I got a wrong tracefile path

    Hi, In initPostgreSQL.ora file,I set ODBCINI=/etc/odbc.ini. In odbc.ini file,I set the tracefile path on /tmp/odbc.log. When I got some error in sqlplus,I will got some log in the trace file. but it always wrote log on /tmp/sql.log. I don't have set