Client Sockets

I want to identify clients.Suppose there are 2 clients and the server wants to identify these two clients how will the server identify them? is there any method to identify the clients?

p
public static class ConnectionHandler1 extends Thread implements Map
Socket conn=new Socket() ;
int idcon=0 ;
Map<Integer,socket> ;
ConnectionHandler(Socket socket,int id)
conn=socket ;
idcon=id ;
sockets=new HashMap<Integer,Socket>();
public void run()
try
System.out.println("Detected client ");
InputStream sin = conn.getInputStream();
OutputStream sout = conn.getOutputStream();
DataInputStream in = new DataInputStream(sin);
DataOutputStream out = new DataOutputStream(sout);
String username = in.readUTF(); // wait for the client to send a line of text.
System.out.println("Reading the username : " + username);
System.out.println("conn : " + conn);
System.out.println("idcon: " + idcon);
/* out.writeUTF("hi!!!!!");
out.writeUTF("I have Detected you!!!!");*/
System.out.println("this is sockets"+sockets) ;
sockets.put(idcon, conn) ;
System.out.println("After sockets put") ;
System.out.println(conn=sockets.get(idcon)) ;
}//try
catch(Exception e)
System.out.println(e) ;
it gives me Null pointer Exception.
Edited by: s_coder on Feb 24, 2009 4:42 AM

Similar Messages

  • How to detect client socket shutdowns in server socket

    Hi,
    Hoping to get some help with this. I am writing this program that implements a socket server that accepts a single client socket (from a third-party system). This server receives messages from another program and writes them to the client socket. It does not read anything back from the client. However, the client (which I have no control over) disconnects and reconnects to my server at random intervals. My issue is I cannot detect when the client has disconnected (normally or due to a network failure), hence am unable to accept a fresh connection from the client. Here's my code for the server.
    ServerSocket serverSocket = null;
    Socket clientSocket = null;
    PrintWriter out = null;
    BufferedReader in = null;
    try{
              if (serverSocket == null){
                    serverSocket = new ServerSocket(4511);
         clientSocket = serverSocket.accept();
         System.out.println("Accepted client request ... ");
         out = new PrintWriter(clientSocket.getOutputStream(), true);
         in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
         System.out.println("Input / Output streams intialized ...");          
         while (true){                              
              System.out.println("Is Client Socket Closed : " + clientSocket.isClosed());
              System.out.println("Is Client Socket Connected : " + clientSocket.isConnected());
              System.out.println("Is Client Socket Bound : " + clientSocket.isBound());
              System.out.println("Is Client Socket Input Shutdown : " + clientSocket.isInputShutdown());
              System.out.println("Is Client Socket Output Shutdown : " + clientSocket.isOutputShutdown());
              System.out.println("Is Server Socket Bound : " + serverSocket.isBound());
              System.out.println("Is Server Socket Closed : " + serverSocket.isClosed());
              messageQueue = new MessageQueue(messageQueueDir+"/"+messageQueueFile);
              //get Message from Queue Head (also removes it)
              message = getQueueMessage(messageQueue);
              //format and send to Third Party System
              if (message != null){
                             out.println(formatMessage(message));
                   System.out.println("Sent to Client... ");
              //sleep
              System.out.println("Going to sleep 5 sec");
              Thread.sleep(5000);
              System.out.println("Wake up ...");
    }catch(IOException ioe){
         System.out.println("initSocketServer::IOException : " + ioe.getMessage());
    }catch(Exception e){
         System.out.println("initSocketServer::Exception : " + e.getMessage());
    }I never use the client's inputstream to read, although I have declared it here. After the client is connected (it enters the while loop), it prints the following. These values stay the same even after the client disconnects.
    Is Client Socket Closed : false
    Is Client Socket Connected : true
    Is Client Socket Bound : true
    Is Client Socket Input Shutdown : false
    Is Client Socket Output Shutdown : false
    Is Server Socket Bound : true
    Is Server Socket Closed : false
    So, basically I am looking for a condition that detects that the client is no longer connected, so that I can bring serverSocket.accept() and in and out initializations within the while loop.
    Appreciate much, thanks.

    Crossposted and answered.

  • When does the RMI Client socket be created?

    Hi, I have created my own RMIClientSocketFactory and RMIServerSocketFactory, it was just a normal socket with some print statements. Example:
    ============================================================
    public class MyRMIClientSocketFactory implements
    RMIClientSocketFactory, Serializable {
    private int hashCode = "MyRMIClientSocketFactory".hashCode();
    public Socket createSocket(String host, int port) throws IOException {
    System.out.println("creating socket to host : " + host + " on port " + port);
    return new Socket(host, port);
    public boolean equals(Object object) {
    if (object instanceof MyRMIClientSocketFactory)
    return true;
    return false;
    public int hashCode() {
    return hashCode;
    public class MyRMIServerSocketFactory implements RMIServerSocketFactory, Serializable {
    private int hashCode = "MyRMIServerSocketFactory".hashCode();
    public ServerSocket createServerSocket(int port) throws IOException {
    System.out.println("creating ServerSocket on port " + port);
    return new ServerSocket(port);
    public boolean equals(Object object) {
    if (object instanceof MyRMIServerSocketFactory)
    return true;
    return false;
    public int hashCode() {
    return hashCode;
    ================================================================
    I wonder when the message "creating socket on port.." and "creating ServerSocket on port.." will be printed? And I found that the equals() and hashCode() methods are called quite a lot of times when I made one rmi call. When I keep the reference of the remote object for some times, the client socket will be created again. Can somebody tell me how all these work?
    Thanks,
    Jax

    Does it
    means that when timeout happened, a new client socket
    will be created and make remote calls to renew DGC
    leases?Yes.
    Again, about exporting remote objects on the same
    port, why I got the exceptions:
    java.rmi.server.ExportException: Port already in use:
    1234;
    nested exception is: java.net.BindException: Address
    already in use: JVM_BindYou get this if you try to export two servers on the same port but their server socket factories are not equal (or not both null or unspecified), or if the two ojbects are in separate JVMs (port sharing can only work inside a single JVM), or if the port is in use by some other listening process.
    Your MyRMIServerSocketFactory.equals() method looks OK to me, but I'd delete the hashCode() method, it's not necessary for RMI and your implementation is flawed. Personally I use the following equals() method:
    public boolean equals(Object that) { return that != null && that.getClass() == this.getClass(); }

  • Client socket binding to the same local/remote addresses

    Hi all,
    My Java program binds client socket to local address, local port, remote address and remote port. after that from different thread the program creates new socket and bind it to the same address as the first one. The question is: is there possibility that the second socket will be copy as the first one (with the same input/output streams) so that two threads in fact use the same TCP connection.
    (Operating system is HP).
    Thank you,
    Kate

    I have no need to store streams, my problem that each connection has it's own messages numbers(the application implements some protocol over TCP). so if a message number 1 was sent by some connection, and when different thread wants to send a message to the same remote host, it tries to pick up existing connection, but because of a bug creates the new one, which sends the message with number 1 also. And I see that there are situation whent the first thread receives response to the message number 1 althougth it was response to the message number 1 that the second thread has sent. So my question is if there is any possibility of this absurd situation?

  • Tracking data on Client Socket

    Hey, help me to figure this out, i have condition like this
    Client request via browser and then the request go through RMI Server, RMI Server create Socket,which is connected to dummy machine, RMI Server send the request to the dummy machine to be proceed, after the dummy machine proceed the request it will sending to RMI Server, and RMI Server forwarded to the client via AppServer...
    My problem are, if i send the request with many client on the same time, i got the data but the data is not what i wanted means that my data go through another client, how to solve this?
    can i create thread on my socket which is connected to the dummy machine (If i use ServerSocket i can thread this,but i'm not using serverSocket) the dummy machine only can connected via socket(client socket type)
    i figure this problem like this, why i got the different response from what i requested,cos if many client request in the same time, my socket not handle FIFO,correct me if i'm wrong? i want to create process like this, if the socket is using, the another client must be wait, is there any method that i can use for tracking the data on the socket?
    I think about another solution, how about creating threads on my RMI at receiving and sending method?
    If there any solution please help me figure this out...
    Thanks....

    There should be a simple applet that continuously checks your account and tells you how much bandwidth usage your computer/device, and all other computers/devices have used so far during your billing period, individually and total for the device/account.
    I consider this situation to be a SERIOUS lacking/missing feature that should have been created BEFORE 4G service and the MiFi 4510L were offered.  The FCC should REQUIRE all wireless providers to provide a VERY simple, automatic method of continuously diplaying bandwidth usage for each account, and for each device using the account.  This is NOT rocket science by any means.
    Steve

  • BindException on client Socket?

    When opening many client sockets under win2k, I am getting BindExceptions. This is without specifying any particular local port. The total number of simultaneous sockets open is only around 14 or 15, but thousands are being opened in a 1-2 minute period.
    A BindException with a Socket(host, port) call seems counter-intuitive. I would assume that the OS is suppose to open it using an unused local port.
    From my testing, it appears that the java.net.Socket() class only obtains local ports from the 1024-5000 port range. It seems to go through the range and wrap around a couple of times before the BindExceptions pop up.
    Note that this appears to be the correct port range to allocate from based on various documentation, even though an equivalent program written in C does not seem to limit itself to that range (and does not exhibit the binding problem).
    If I set the windows registry entry of MaxUserPort to a higher number, it takes longer for the BindException to occur since it has more ports to utilize. However, the problem doesn't go away.
    Has anyone else seen this issue and come up with a solution? (Looping on the socket creation does not seem to be a very good long term solution)
    Attached is a simple program which demonstrates the issue by making multiple HEAD requests to a webserver.
    SockTest.java:
    public class SockTest
         public static void main(java.lang.String[] args)
              int i;
              for (i = 0; i < 14; i++)
                   SockTestThread thread = new SockTestThread();
                   thread.start();
    }SockTestThread.java:
    public class SockTestThread extends java.lang.Thread
         private void runTransaction(java.lang.String hostname, int port)
              try
                   java.net.Socket sock;
                   java.io.PrintStream out;
                   java.io.InputStream in;
                   java.lang.String request = "HEAD / HTTP/1.0\n\n";
                   byte[] response = new byte[4096];
                   sock = new java.net.Socket(hostname, port);
                   out = new java.io.PrintStream(sock.getOutputStream());
                   in = sock.getInputStream();
                   java.lang.System.out.println("Making request from local port " + sock.getLocalPort());
                   out.print(request);
                   out.flush();
                   in.read(response);
                   sock.close();
              catch (java.lang.Exception exception)
                   java.lang.System.out.println(exception);
         public void run()
              int i;
              for (i = 0; i < 1000; i++)
                   this.runTransaction("webserver", 80);
              java.lang.System.out.println("Finished thread");

    There is only ever 14 sockets open at any one time. You will notice that the 1000 connections are done serially for each of the 14 threads. So, a socket is opened and closed (released) after each connection.
    I'm not sure how a socket pool could be used/implemented here to help this. Also, up until the recent JDK1.4 release, there didn't appear to be a way to reuse a client socket. As far as I can tell, one can only create new sockets. Also, JDK 1.4 is not currently an option for me.
    While this sample program just connects to a single web server to demonstrate the issue, the real application will be connecting to many different servers (web and others) and needs to be able to process the information and move on after each connection.

  • Closing a client socket

    I have a chat application.
    My server has a serversocket that listens on a port various client sockets.
    the server is multithreaded, a thread per connected client.
    the client application uses a thread to listen for messages from server.
    the run method in the client is a
    while(messageFromServer.equals("OVER"))
    Also, the client has a GUI with a menu with 2 menu items:
    Connect
    Disconnect
    on Connect, i create the socket, i create the 2 streams(in and out)
    and write something to the server and start the thread for reading from the socket.
    my problem:
    I can't disconnect without blocking the application.
    Voila the code that blocks it:
    public void terminate_connection()
    write_on_socket("OVER");
    try
    in.close();
    out.flush();
    out.close();
    terminal.close();
    catch(IOException ioe)
    System.out.println("eroare"+ioe);
    in=the inputstream on the socket
    out=the outputstream on the socket
    terminal= the socket
    I have tried to debug with System.out.println(error)
    and it seems to stop execution when i try to close the inputstream
    in.close();
    Can someone please help me by telling me where I am wrong
    or showing me some good code of disconnecting a socket and to notify also the peer socket that the socket is terminating(dying).
    Thanx in advance.
    Gabi

    While I'm not sure why your code is blocking...I put together a test chat program to try and help...maybe you can see something that you are doing differently...the following is 'ClientServer.java' compile and run 'ClientServer'.
    import java.net.*;
    import java.io.*;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    class Server extends Thread{
         private ArrayList clients;
         public void run(){
              clients = new ArrayList();
              try{
                   ServerSocket ss = new ServerSocket(8181);
                   while(true){
                        try{
                             ServerThread th = new ServerThread( ss.accept(), this );
                             clients.add( th );
                             th.start();
                        }catch(Exception ex2){
                             ex2.printStackTrace();
              }catch(Exception ex){
                   ex.printStackTrace();
         public void sendToAll(String text){
              Iterator iter = clients.iterator();
              while( iter.hasNext() ){
                   ServerThread st = (ServerThread)iter.next();
                   try{
                        st.send( text );
                   }catch(Exception ex){
                        iter.remove();
    class ServerThread extends Thread{
         private Socket s;
         private PrintStream out;
         private BufferedReader in;
         private Server server;
         public ServerThread(Socket s, Server server)throws IOException{
              this.server = server;
              this.s = s;
              this.in = new BufferedReader( new InputStreamReader( s.getInputStream() ) );
              this.out = new PrintStream( s.getOutputStream() );
         public void run(){
              try{
                   String text = "";
                   do{
                        text = in.readLine();
                        server.sendToAll( text );
                   }while( !text.equals( "QUIT" ) );
                   in.close();
                   s.close();
              }catch(Exception ex){
                   ex.printStackTrace();
         public void send(String st){
              out.println(st);
    class Client extends JFrame{
         Socket s;
         PrintStream out;
         BufferedReader in;
         private JTextArea messageArea;
         private JTextField textField;
         public Client(){
              super("Client Window");
              JPanel buttonPanel = new JPanel();
              JButton connect = new JButton("Connect");
              connect.addActionListener( new ActionListener(){
                   public void actionPerformed( ActionEvent evt ){
                        connect();
              buttonPanel.add( connect );
              JButton disconnect = new JButton("Disconnect");
              disconnect.addActionListener( new ActionListener(){
                   public void actionPerformed( ActionEvent evt ){
                        disconnect();
              buttonPanel.add( disconnect );
              getContentPane().add(BorderLayout.SOUTH, buttonPanel);
              messageArea = new JTextArea();
              messageArea.setEditable( false );
              getContentPane().add( messageArea);
              JPanel textPanel = new JPanel();
              textPanel.setLayout(new BorderLayout());
              ActionListener sendAction = new ActionListener(){
                   public void actionPerformed( ActionEvent evt ){
                        if( ! "".equals( textField.getText() ) ){
                             out.println( textField.getText() );
                             textField.setText("");
              textField = new JTextField();
              textField.addActionListener( sendAction );
              textPanel.add( textField );
              JButton sendButton = new JButton("send");
              sendButton.addActionListener( sendAction );
              textPanel.add( BorderLayout.EAST, sendButton );
              getContentPane().add(BorderLayout.NORTH, textPanel);
              setSize(200, 300);
              setVisible(true);
              setDefaultCloseOperation(EXIT_ON_CLOSE);
         public synchronized void connect(){
              if( s == null ){
                   try{
                        s = new Socket("localhost", 8181);
                        out = new PrintStream( s.getOutputStream() );
                        in = new BufferedReader( new InputStreamReader( s.getInputStream() ) );
                        (new ClientThread( this )).start();
                        out.println("connected");
                   }catch(Exception ex){
                        ex.printStackTrace();
         public synchronized void disconnect(){
              if( s != null ){
                   try{
                        out.println("QUIT");
                        out.close();
                        s.close();
                        s = null;
                   }catch(Exception ex){
                        ex.printStackTrace();
         public void addMessage(String st ){
              messageArea.append( st + "\n");
         public BufferedReader getReader(){
              return in;
    class ClientThread extends Thread{
         private Client c;
         public ClientThread( Client c ){
              this.c = c;
         public void run(){
              BufferedReader reader = c.getReader();
              try{
                   while(true){
                        c.addMessage( reader.readLine() );
              }catch(Exception ex){
                   ex.printStackTrace();
    public class ClientServer{
         public static void main(String[] args){
              (new Server()).start();
              new Client();
    }

  • Server/Client Socket Connection

    Hi, I am trying to program a simple server/client socket connection program, the main function is to send and receive objects between them. I somehow went wrong and the connection between them keeps terminating right after establishing connection. Is there anything I can do to resolve this?
    This is gonnna be kinda long post.. sorry. These are the code that starts and ends the socket connection. I'm kinda desperate for this to work.. so thanks in advance.
    appinterface.java:
    //Set up server to receive communications; process connections. 1x.
         public void runServer () {
              try {
                   //Create a ServerSocket
                   server = new ServerSocket(12345, 100);
                   try {
                             waitForSockConnection();     //Wait for a connection.
                             getSockStreams();               //Get input & output streams.
                             establishDbConnection();     //Open up connection to DB.
                   finally {
                             closeSockConnection(); //Close connection.
              //Process problems with I/O
              catch(IOException ioException) {
                   displayMessage("I/O Error: " + ioException);
                   runServer();
         //Wait for connection to arrive, then display connection info
         private void waitForSockConnection() throws IOException {
              displayMessage("Waiting for connection");
              connection = server.accept(); //Allow server to accept connection.
              displayMessage("Connection received from: " + connection.getInetAddress().getHostName());
         //Get streams to send and receive data.
         private void getSockStreams() throws IOException {
              //Set up output streams for objects
              ObjectOutputStream output = new ObjectOutputStream(connection.getOutputStream());
              output.flush(); //Flush output buffer to send header information.
              //Set up input stream for objects.
              ObjectInputStream input = new ObjectInputStream(connection.getInputStream());
              try {
              classHolderServer holderObj = new classHolderServer();
              holderObj = (classHolderServer)input.readObject();
              processSockConnection(holderObj);
              displayMessage("Got I/O Streams");
              //Catch problems reading from client
              catch (ClassNotFoundException classNotFoundException) {
                             displayMessage("Unknown object type received");
         //Process connection with client.
         private void processSockConnection(classHolderServer holderObj) throws IOException {
              //sendMessage("Connection Successful");
                        //True is query, and false is auth.
                        if(holderObj.type1==true)
                             processDbStatement(holderObj.type2, holderObj.sqlquery);
                        else {
                             authCheck(holderObj.userName, holderObj.passWord);
                             if(!authCheck)
                             closeDbConnection();
         //Send messages to client.
         private void sendMessage(String message) {
              // Send message to client
              try {
                   ObjectOutputStream output = new ObjectOutputStream(connection.getOutputStream());
                   output.flush();
                   output.writeObject(message);
                   output.flush();
                   displayMessage("Message Sent:" + message);
              catch (IOException ioException) {
                   displayMessage("\nError Sending Message: " + message);
         //Send object to client
         private void sendObject(Object holderObj) {
                   // Send object to client
                   try {
                        ObjectOutputStream output = new ObjectOutputStream(connection.getOutputStream());
                        output.writeObject(holderObj);
                        output.flush();
                        displayMessage("\nObject sent");
                   //Process problems sending object
                   catch (IOException ioException) {
                        displayMessage("\nError writing object");
         //Close streams and socket.
         private void closeSockConnection() {
                   displayMessage("Terminating connection");
                   try {
                        //output.close();
                        //input.close();
                        connection.close();
                        closeDbConnection();
                        this.userName = null;
                        this.passWord = null;
                        this.receiverId = 0;
                        this.authCheck = false;
                   catch (IOException ioException) {
                        displayMessage("I/O Error: " + ioException);
              }Client:
    private void runClient() {
              //Connect to sever and process messages from server.
              try{
                   connectToServer();
                   getStreams();
                   processConnection();
              //Server closed connection.
              catch(EOFException eofException) {
                   //displayMessage"Client Terminated Connection");
              //Process problems communicating with server.
              catch (IOException ioException) {
                   //displayMessage"Communication Problem");
              finally {
                   closeConnection();
         //Connect to server
         private void connectToServer() throws IOException {
              //displayMessage("Attempting connection\n");
              //Create Socket to make connection to sever.
              client = new Socket(InetAddress.getByName(chatServer), 12345);
              //Display connection information
              //displayMessage("Connected to: " + client.getInetAddress().getHostName());
         //Get streams to send and receive data.
         private void getStreams() throws IOException {
              //Set up output stream for objects.
              ObjectOutputStream output = new ObjectOutputStream(client.getOutputStream());
              output.flush(); //Flush outout buffer to send header information.
              //Set up input stream for objects.
              ObjectInputStream input = new ObjectInputStream(client.getInputStream());
              //displayMessage("\nGot I/O streams\n");
         //Close socket connection.
         private void closeConnection() {
              //displayMessage("\nClosing connection");
              try {
                   ObjectOutputStream output = new ObjectOutputStream(client.getOutputStream());
                   output.close();
                   ObjectInputStream input = new ObjectInputStream(client.getInputStream());
                   input.close();
                   client.close();
                   authCheck=false;
              catch(IOException ioException) {
                   ioException.printStackTrace();
         //Send data to server.
         private void sendObject(classHolderClient queryObj) {
              try {
                   output.writeObject(queryObj);
                   output.flush();
                   //displayMessage("Please wait..");
              //Process problems sending object.
              catch (IOException ioException) {
                   //displayMessage("\nError writing object");
         //Process connection with server.
         private void processConnection() throws IOException {
              try{
                   classHolderClient holderObj = new classHolderClient();
                   holderObj = (classHolderClient)input.readObject();
                   if(holderObj.type2==2) {
                             this.authCheck=holderObj.authCheck;
                             this.userName=holderObj.userName;
                             this.passWord=holderObj.passWord;
              catch(ClassNotFoundException classNotFoundException) {
                   //displayMessage(classNotFoundException);
              }

    private ObjectOutputStream output = new ObjectOutputStream(client.getOutputStream());Like this? But this will cause an error asking me to catch an exception:
    C:\Documents and Settings\Moon\My Documents\Navi Projects\School\OOPJ Project\Prototype\GPS-Lite v2 Alpha Debugger\client.java:41: unreported exception java.io.IOException; must be caught or declared to be thrown
            private ObjectOutputStream output = new ObjectOutputStream(client.getOutputStream());
                                                                                             ^
    C:\Documents and Settings\Moon\My Documents\Navi Projects\School\OOPJ Project\Prototype\GPS-Lite v2 Alpha Debugger\client.java:41: unreported exception java.io.IOException; must be caught or declared to be thrown
            private ObjectOutputStream output = new ObjectOutputStream(client.getOutputStream());
                                                ^
    2 errors

  • Open client socket from within a Web Service

    Hello,
    I need to open a client TCP/IP socket from within a Web Service-type WebLogic
    Workshop app. When I try to read from the socket, the socket read operation hangs.
    When I use the same code in a J2SE Java app on the same machine using Eclipse
    everything works fine. It also works fine from within WebLogic, if I use a "URL"
    object instead of a "Socket" object. (However, I cannot use this type of connection.)
    Can anyone tell me how to work with raw TCP/IP sockets in this situation?

    Hi Udi,
    I have tested my code from within a Servlet and it works fine.
    The Servlet and the Web Service both call the same simple JAVA class. This class wants to access a DB, and therefor, I am using the Data Source.
    When the Servlet calls the class, everything works fine. But when I use the Web Service to call this class, I get the Exception "No attributes are implemented".
    I hope this information helps you understanding my problem?
    Thank you very much for your help.
    Kind regards,
         Nadine

  • Increasing Weblogic client Socket Readers etc

    How can you increase the number of socket readers on a client
    application which
    uses JMS, EJB and talks to multiple WLAS servers.
    I get the following message
    Muxer> <There are: '3' active sockets, but the maximum number of socket
    readers allowed by theconfiguration is: '2', you may want alter your
    configuration.>
    But I cant find out how to increase the socket readers or better yet can
    I use the native IO for Solaris and NT clients??

    Hi,
    You can control the number of threads and the precent of socket readers
    through the properties: weblogic.ThreadPoolSize and
    weblogic.ThreadPoolPercentSocketReaders. You would have to pass them to the
    jvm machine at startup for example:
    -Dweblogic.ThreadPoolSize=10 -Dweblogic.ThreadPoolPercentSocketReaders=50
    Guy
    "Larry Presswood" <[email protected]> wrote in message
    news:[email protected]..
    How can you increase the number of socket readers on a client
    application which
    uses JMS, EJB and talks to multiple WLAS servers.
    I get the following message
    Muxer> <There are: '3' active sockets, but the maximum number of socket
    readers allowed by theconfiguration is: '2', you may want alter your
    configuration.>
    But I cant find out how to increase the socket readers or better yet can
    I use the native IO for Solaris and NT clients??

  • Java client socket readers

              I'm running a cluster of 3 WL 6.0 servers and when I do a JNDI lookup to run methods
              on a remote interface stub on the client side it gives me the following:
              <Apr 26, 2001 2:16:34 PM MST> <Warning> <JavaSocketMuxer> <There are: '3' active
              sockets, but the maximum number of socket readers allowed by theconfiguration
              i
              s: '2', you may want alter your configuration.>
              I re-ran my client with the two following properties:
              -Dweblogic.system.executeThreadCount=5
              -Dweblogic.system.percentSocketReaders=60
              it still gives me the exception. How do I get this to work properly so I have
              as many socket readers as servers?
              Thanks in advance.
              

    Thanks,
              I had understood this wrong, I was configuring on the server, not the client
              application,
              it's all working well now.
              Cheers
              Sioux
              "Kumar Allamraju" <[email protected]> wrote in message
              news:[email protected]...
              > i.e. if percentSocketReaders = 50, and execute Threadcount is 20, 50% of
              20 = x?
              >
              > you will get x percentSocketReaders. You might want to tune this value ,
              > according to the above
              > formula.
              >
              >
              > Sioux France wrote:
              >
              > > Hi,
              > > I'm getting these errors too. I've enabled native IO, upped the number
              of
              > > Threads to 20 and the percentage of readers to 50% but I still get the
              error
              > > about 3 active sockets when I am only allowed 2 in a cluster of 3
              servers.
              > > Did you resolve this?
              > > Thanks
              > > Sioux
              > >
              > > "Kumar Allamraju" <[email protected]> wrote in message
              > > news:[email protected]...
              > > > The following syntax was correct in 510. , not in 60 anymore.
              > > > I would suggest you to increase the execute Thread count & percent
              socket
              > > readers from
              > > > console.
              > > >
              > > > or else set the following from the command line.
              > > > -Dweblogic.ThreadPoolPercentSocketReaders
              & -Dweblogic.ThreadPoolSize..
              > > (i'm not 100%
              > > > sure)
              > > > --
              > > > Kumar
              > > >
              > > > "W. Wen" wrote:
              > > >
              > > > > I'm running a cluster of 3 WL 6.0 servers and when I do a JNDI
              lookup to
              > > run methods
              > > > > on a remote interface stub on the client side it gives me the
              following:
              > > > >
              > > > > <Apr 26, 2001 2:16:34 PM MST> <Warning> <JavaSocketMuxer> <There
              are:
              > > '3' active
              > > > > sockets, but the maximum number of socket readers allowed by
              > > theconfiguration
              > > > > i
              > > > > s: '2', you may want alter your configuration.>
              > > > >
              > > > > I re-ran my client with the two following properties:
              > > > >
              > > > > -Dweblogic.system.executeThreadCount=5
              > > > > -Dweblogic.system.percentSocketReaders=60
              > > > >
              > > > > it still gives me the exception. How do I get this to work properly
              so I
              > > have
              > > > > as many socket readers as servers?
              > > > >
              > > > > Thanks in advance.
              > > >
              >
              

  • Client Socket Problem: retrieving data from my Simple http Server...

    here's the main part of the "sending" of data from my server class:
    write(b.getBytes());
    outtStream.write(version.getBytes());
    outStream.write(replyCode.getBytes());
    here the server sends the data back to the client...i've tested this on a webbrowser and got a correct response...
    now in my client side, I'm having problems...
    1) I dont know how to retrieve the data from the outStreams above...
    2) Can anyone give me some help plz...or descriptive sample code
    here's the main part of the client sending its data first from the user input(client) and then sending the data...(ive created the socket)
    input = new BufferedReader(new InputStreamReader(System.in));
    output = new PrintWriter(socket.getOutputStream(),true);
    while((message = input.readLine()) != null)
    output.println(message);//sends the client's input to server?
    System.out.println(input.readLine());//retrieves server's response
    //then outputs it

    also i tried adding
    input = new BufferedReader(new InputStreamReader(socket.getInputStream()));
    after the System.in one and still no luck :[                                                                                                                                                                                                                                                                                               

  • Simple server/client socket in applets code.

    Can anyone please help me with Java sockets ? I want to create an applet that simply checks if it's still online. This means that i'll be using this applet thru modem(that is, dial-up connection). All i want the applet to do is send a signal to the server and the server answer back that it is still online. The server should be able to handle multiple sends and receives. I need just a simple code for me to work on (both server and client). The client doesn't have to send any special message to the server and vice versa.
    Thanks.

    Below is the code for both Applet and Servlet .I think this will solve your problem.
    Applet:
    import java.applet.*;
    import java.awt.*;
    import java.io.*;
    import java.net.*;
    public class OnlineApplet extends Applet implements Runnable
         private static Thread thread;
         private static HttpURLConnection URLConn;
         public void init()
              try
                   //Connect to the URL where servlet is running.
                   URL url = new URL("http://localhost/servlet/OnlineServlet");
                   URLConn = (HttpURLConnection)url.openConnection();
                   URLConn.setDoInput(false);
                   URLConn.setDoOutput(true);
              catch (Exception ex)
              thread = new Thread(this);
         public void start()
              thread.start();
         public void paint(Graphics g) {}
         public void stop() { }
         public void destroy() { }
         public void run()
              while(true)
                   try
                        thread.sleep(1000 * 60);
                        sendConfirmation();
                   catch (Exception ex)
         private void sendConfirmation() throws Exception
              DataOutputStream dos = new DataOutputStream(URLConn.getOutputStream());
              dos.writeChars("Fine");
              dos.flush();
              dos.close();
    Servlet:
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.util.*;
    public class OnlineServlet extends HttpServlet implements Runnable
         public static Hashtable hsh;
         private static Thread thread;
         public void init(ServletConfig scon) throws ServletException
              hsh = new Hashtable();
              thread = new Thread(this);
         public void service(HttpServletRequest req, HttpServletResponse res)
              String strHostName = req.getRemoteHost();
              if(hsh.containsKey(strHostName))
                   updateHash(strHostName);
              else
                   hsh.put(strHostName, System.currentTimeMillis() + "");
         private void updateHash(String strHostName)
              hsh.remove(strHostName);
              hsh.put(strHostName, System.currentTimeMillis() + "");
         public void run()
              while(true)
                   try
                        thread.sleep(1000 * 120);
                   catch (Exception ex)
                   validateUsers(System.currentTimeMillis());
         private void validateUsers(long msec)
              Enumeration keys = hsh.keys();
              int size = hsh.size();
              while(keys.hasMoreElements())
                   String strKey = keys.nextElement().toString();
                   String strLong = hsh.get(strKey).toString();
                   long lg1 = Long.parseLong(strLong);
                   if((lg1 - msec) > 100000)
                        // This means there is no response from user . That means he is not online. So you can remove from hashtable.
                        hsh.remove(strKey);

  • Client/socket design problem

    i am having a client /server design where in the client talks to the server via sockets and i am putting code ofboth the client as well as server in the different loop while(true) at respective ends so that they can talk as long as they would like to but the client hangs upon receiving response from server . please guide me what to do.
    the client side code is
    while(true)
    temp1=clientbfr.readLine();
    //System.out.println(temp);
    if(temp1==null)
    else if(temp1.indexOf("Login-")==0)
    System.out.println(temp1);
    temp1="";
    the server side code is the same and that works fine. again if a second clinet requests a socket to the server then that client also hangs. so i think i am not able to view the picture properly. please guide me.

    Is the server reading before writing? If so, the client will hang until it has sent something for the server to reply to.

  • Client Socket Reconnect Question

    I have a client that is connecting a socket to a piece of hardware (Computer Controlled Telescope). No guarantee that the hardware is powered up when the app starts and the hardware might power down and back up at any time.
    The app�s main thread creates a socket to the device. A child thread gets the socket�s OutputStream to send commands to the device. Another child thread gets the socket�s InputStream to receive status from the device.
    Problem: How do I recognize that the device has died? What do I have to do to the socket to reconnect it?

    I only pass the InputStream and OutputStream to my child threads. The Socket stays snug and secure in my main thread.
    Also, I don't want to hide the fact the socket has gone away, just the opposite , I want to know that the socket has died (Socket.isConnected(), I guess), recreate it to the same IP address, and re-distribute the In/Out Streams to the child threads.
    I guess my questions are: 1) How can I tell that the thread has died? and 2) How do I recreate the socket?

Maybe you are looking for

  • Photoshop CC 2014 on Mac Book Pro Retina (late 2013) crashes alot on random tasks in OSX Yosemite

    When I am busy in Photoshop CC 2014 (latest version) postprocessing photos OSX crashes and no error message appears. These instability problem occur with random tasks in Photoshop. Mac osx is up to date and also tested with the graphic processor disa

  • Crystal Reports - Report Creation Error

    Hello! I've been working with ACT! Premium 2010 and Crystal Reports for about 2 weeks now. Friday we decided we needed to create a new database to work with, we had to scrap all old reports and start new. We created the main database on Friday and po

  • How to use GROUP BY  in ODI

    how to use GROUP BY in ODI tool

  • Can't import JPGS

    Just trying to import some jpgs from a scanner. and i get this message on SOME of them, they are typically greyed-out. When i select "All Files" they are blacked in but i get this message. "Import: File error: 1 files(s) recognized, 0 access denied 1

  • Seeking advice for a wookiee video person...

    I'm shooting alot of videos lately. Typically - they just sit in a folder when I transfer via usb to my dell laptop (sorry I don't have a Macbook pro quite yet!). I know there is Windows Movie Maker and some other "free" junk out there. I see Camtasi