Socket connetion issue

Hi,
I wrote multi thread socket programming.All clients are connected from different network switches.In case any one network switch go to down (power off) / unplug network cable between switches. In this case server program how to identify the connection status or how to know the whether client is connected or not.
Thanks in advance

Hmm, yes.
you can try thisYou can try this yourself, and you will find out that there are many circumstances in which it just sit there forever.
Please don't post misinformation or guesses in these forums.
You could try it with a read timeout, then you might have something, but then you don't know whether the peer is just slow at responding or the network is down.
The only way to detect a dropped TCP connection is to write to it.
Please also note that the methods Socket.isClosed(), Socket.isConnected(), etc, don't tell you about the state of the connection. They tell you about the state of the local Socket, i.e. they tell you which APIs you have called yourself on the socket.

Similar Messages

  • Socket security issues

    Hello,
    I am developing an messaging application, similar to MSN or AIM. so only text messages are passed over a socket.
    Does anybody know of any socket security issues there are when opening a socket on a particular port in java?
    If so then does anybody know if there is any documentation out there that i can look at?
    Thanks

    psamatt wrote:
    Hello,
    I am developing an messaging application, similar to MSN or AIM. so only text messages are passed over a socket.
    Does anybody know of any socket security issues there are when opening a socket on a particular port in java?
    If so then does anybody know if there is any documentation out there that i can look at?
    Simple sockets are wide open - there is no security. Secure sockets are implemented as a layer on top of simple sockets using JSSE - http://java.sun.com/j2se/1.4.2/docs/guide/security/jsse/JSSERefGuide.html .

  • OC4J bind socket address issue

    Hi i am using DB(9.2.0.6.0) and APPS(11.5.10.2).  Now i have cloned a new instance and it runs on port 8050. Now i want to install and configure OC4J with it. I have done the OC4J Installation Successfully. Here i used the OC4J Version 9.0.3.I have changed the http-web-site.xml port number to 8890 and rmi.xml port to 23793 as per the document i got.To create the starting script, file name called “.start_oc4j” I issued cd $OC4J_TOP/j2ee/home/ then
    java -jar oc4j.jar and
    it throws the error
    [applpdev@oraapps ~]$ cd $OC4J_TOP
    [applpdev@oraapps home]$ pwd
    /pdev/p01/oracle/pixappl/pwr/11.5.0/oc4j/
    [applpdev@oraapps oc4j]$ cd j2ee/home/
    [applpdev@oraapps home]$ java -jar oc4j.jar
    Error starting JMS-Server: Unable to bind socket: Address already in use
    Error starting ORMI-Server.  Unable to bind socket: Address already in use
    [applpdev@oraapps home]$

    Hi Hussein,
         Now i am facing a new issue. I am using oc4j 9.0.3 version. When i started the oc4j i am getting the following error.
    [applpdev@oraapps home]$ java -jar oc4j.jar
    Auto-deploying ejb (No previous deployment found)... Exception in thread "Orion Launcher" java.lang.NoClassDefFoundError: sun/jdbc/rowset/CachedRowSet
            at java.lang.Class.getDeclaredMethods0(Native Method)
            at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
            at java.lang.Class.privateGetPublicMethods(Class.java:2547)
            at java.lang.Class.getMethods(Class.java:1410)
            at
    com.evermind.server.ejb.compilation.ClassCompilation.compileMethods(ClassCompilation.java:84)
            at com.evermind.server.ejb.compilation.StatelessSessionBeanCompilation.compile(StatelessSessionBeanCompilation.java:40)
            at com.evermind.server.ejb.compilation.Compilation.compile(Compilation.java:288)
            at com.evermind.server.ejb.EJBContainer.postInit(EJBContainer.java:551)
            at com.evermind.server.Application.postInit(Application.java:431)
            at com.evermind.server.Application.setConfig(Application.java:136)
            at com.evermind.server.ApplicationServer.addApplication(ApplicationServer.java:1635)
            at com.evermind.server.ApplicationServer.initializeApplications(ApplicationServer.java:1585)
            at com.evermind.server.ApplicationServer.setConfig(ApplicationServer.java:1240)
            at com.evermind.server.ApplicationServerLauncher.run(ApplicationServerLauncher.java:93)
            at java.lang.Thread.run(Thread.java:662)
    Caused by: java.lang.ClassNotFoundException: sun.jdbc.rowset.CachedRowSet
            at com.evermind.naming.ContextClassLoader.findClass(ContextClassLoader.java:456)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
            at com.evermind.naming.ContextClassLoader.loadClass(ContextClassLoader.java:135)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
            ... 15 more
    So i uninstalled jdk1.6.0 and installed jdk1.4.2 and i started the OC4J. The default web page is displayed. Now i moved a .ear file to the directory APPL_TOP/pwr/11.5.0/oc4j/j2ee/home/applications added the entries in the server.xml,application.xml,http-web-site.xml and the directory is created for the respective .ear file. Under the path APPL_TOP/pwr/11.5.0/oc4j/j2ee/home/applications there are two default directories called dms0 and dms and they are accessible through the browser but my directory created by the .ear file is not accessible through the browser and it throws the error Can't find the directory. I checked the log and the content is
    12/5/13 6:06 PM iLogin: JspServlet: unable to dispatch to requested page: Exception:oracle.jsp.provider.JspCompileException: <H3>Errors compiling:/pdev/p01/oracle/pixappl/pwr/11.5.0/oc4j/j2ee/home/application-deployments/iLogin/iLogin/persistence/_pages//_iLogin.java</H3><pre>error: Invalid class file format in /usr/java/j2sdk1.4.2_19/jre/lib/rt.jar(java/io/PrintWriter.class).  The major.minor version '48.0' is too recent for this tool to understand.
    /pdev/p01/oracle/pixappl/pwr/11.5.0/oc4j/j2ee/home/application-deployments/iLogin/iLogin/persistence/_pages/_iLogin.java:11: Class java.io.PrintWriter not found in import.
    import java.io.PrintWriter;
           ^
    error: Invalid class file format in /usr/java/j2sdk1.4.2_19/jre/lib/rt.jar(java/io/IOException.class).  The major.minor version '48.0' is too recent for this tool to understand.
    /pdev/p01/oracle/pixappl/pwr/11.5.0/oc4j/j2ee/home/application-deployments/iLogin/iLogin/persistence/_pages/_iLogin.java:12: Class java.io.IOException not found in import.
    import java.io.IOException;
           ^
    error: Invalid class file format in /usr/java/j2sdk1.4.2_19/jre/lib/rt.jar(java/sql/Connection.class).  The major.minor version '48.0' is too recent for this tool to understand.
    /pdev/p01/oracle/pixappl/pwr/11.5.0/oc4j/j2ee/home/application-deployments/iLogin/iLogin/persistence/_pages/_iLogin.java:14: Class java.sql.Connection not found in import.
    import java.sql.Connection;
    </pre>
    12/5/13 6:06 PM iLogin: Recursive error in error-page calling for /iMODError.jsp
    javax.servlet.ServletException: Recursive error in error-page calling for /iMODError.jsp (status 500)
      at com.evermind[Oracle9iAS (9.0.3.0.0) Containers for J2EE].server.http.EvermindHttpServletResponse.sendError(EvermindHttpServletResponse.java:1204)
      at oracle.jsp.runtimev2.JspReportUtil.sendError(JspReportUtil.java:96)
      at oracle.jsp.runtimev2.JspReportUtil.reportException(JspReportUtil.java:125)
      at oracle.jsp.runtimev2.JspPageTable.compileAndServe(JspPageTable.java:573)
      at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:272)
      at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:465)
      at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:379)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      at com.evermind[Oracle9iAS (9.0.3.0.0) Containers for J2EE].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:721)
      at com.evermind[Oracle9iAS (9.0.3.0.0) Containers for J2EE].server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:306)
      at com.evermind[Oracle9iAS (9.0.3.0.0) Containers for J2EE].server.http.ServletRequestDispatcher.forward(ServletRequestDispatcher.java:209)
      at com.evermind[Oracle9iAS (9.0.3.0.0) Containers for J2EE].server.http.EvermindHttpServletResponse.sendError(EvermindHttpServletResponse.java:1244)  and the same errors are repeated

  • Server socket programming issue

    Hi there and thanks for visiting my post,
    I'm writing a instant message application. I've written a multi-threaded server that constant listens for socket connections on port 4001. When a connection is received by the server, it adds the thread (client) connection to an array (of fixed size, I allow a max of 100 connections or so) and starts the thread. Here's the code:
    import java.io.*;
    import java.util.*;
    import java.net.*;
    * @author Stephen
    public class Main {
        static ServerSocket         sock = null;
        static pmClientHandler      conn;
        static Socket               client = null;  
        static int                  port = 4001;
        static int                  MAX_CONNECTIONS = 100;
        static pmClientHandler      t[] = new pmClientHandler[MAX_CONNECTIONS]; // array that holds threads holds a max of 100 now
        /** Creates a new instance of Main */
        public Main() { }
         * Instantiate server listener
         * @param args the command line arguments
        public static void main(String[] args) {
            // TODO code application logic here
            try {
                sock = new ServerSocket(port);  // listen on port
            } catch (IOException e) {
                System.out.println("Cannot create server on port "+port+".");
                System.exit(1);
            System.out.println("Pita messenger server ready on port  "+port+". Listening for connections...\n\n");
            while (true) {    // infinite loop to listingen for many connections
                try {
                client = sock.accept();  // accept connection
                for (int i =0; i < MAX_CONNECTIONS; i++) {
                    if (t[i] == null) {
                       (t[i] = new pmClientHandler(client,t,MAX_CONNECTIONS)).start();
                       break;      
                } catch (IOException e) {  // ERROR ACCEPTING CONNECTION 
            } // end infini. loop listening for remote socket connections
    }Again, each instance thread object of pmClientHandler constantly listens for incoming messages from the client application. Here's the code for that class.
    import java.util.*;
    import java.net.*;
    import java.io.*;
    public class pmClientHandler extends Thread {
    public String       username = "";
    private boolean     userValidated = false;
    public boolean      userAway = false;
    public boolean      userInvisible = false;
    public boolean      userBusy = false;
    private ArrayList   currentBuddyList;
    public Socket      connection;
    public pmClientHandler t[];
    private Scanner     reciever;
    public PrintStream  sender = null;
    private int         MAX_CONNECTIONS;
    private boolean     isConnected = false;
        /** Creates a new instance of pmClientHandler */
        public pmClientHandler(Socket s, pmClientHandler[] newThread, int maxc) {
            connection = s; // hand over socket
            MAX_CONNECTIONS = maxc;
            t = newThread; // hand over thread. We now have new populate array of clients in t[]
            isConnected = true;  // user connected
            try {  // create IO streams for this particular client
                reciever = new Scanner(connection.getInputStream()); 
                sender = new PrintStream(connection.getOutputStream(), true);  //auto flush true
            } catch (IOException e) { close(); }
         * Required method by threads. Method is called when thread is executed.
         public void run() {
          String clientMessage;
          pmServerMessenger resource = new pmServerMessenger();
          while(isConnected) { 
            // Determine username and password request
            clientMessage = reciever.nextLine().trim();
            ///////////////////////  HANDLE PROTOCOL / MESSAGES  /////////////////////////////////
            // So we know user has established a connection to the server but has not yet logged in yet.
            if (clientMessage.toUpperCase().startsWith("ECHO")) { sender.println("ECHO BACK, HELLO CLIENT"); }
            if (clientMessage.startsWith("LOGIN")) {  // client wishes to log in
                clientMessage = clientMessage.substring(5).trim();
                if (clientMessage.indexOf(" ") != -1) {
                    String suppliedUsername, suppliedPassword;
                    suppliedUsername = clientMessage.substring(0, clientMessage.indexOf(" ")).trim();
                    suppliedPassword = clientMessage.substring(clientMessage.indexOf(" ")).trim();
                    // Valid user
                    if (resource.validateUser(suppliedUsername, suppliedPassword)) {    
                        sender.println("ACDFG324323DSSDGTRR54745345DFGDFSE3423423DHDFHER4565DFGDFGERT");  // send key to client
                        userValidated = true;   // set flag to allow user to access server resources.
                        this.username = suppliedUsername;
                    } else {
                        sender.println("INVALIDLOGIN");
                } else {
                    sender.println("INVALIDLOGIN");
                    this.close();
            } // end user login routine //////////////////////////////////////////////
            if (clientMessage.toUpperCase().startsWith("LOADBUDDYLIST")) {
                if (isConnected && userValidated) {
                    ArrayList thisUsersBuddyList = resource.getBuddyList(this.username);
                    for (int i = 0; i < thisUsersBuddyList.size(); i++) {
                        String currBuddy = (String) thisUsersBuddyList.get(i);
                        if (currBuddy != "" && currBuddy != null) {
                            sender.println(currBuddy);
                    sender.println("ENDBUDDYLIST");  // let client know we're done sending client buddy list
            if (clientMessage.toUpperCase().startsWith("ISONLINE")) {
                String usrToCheck = clientMessage.substring(8).trim();
                if (isOnline(usrToCheck)) {
                    sender.println("YES "+usrToCheck);
                } else {
                    sender.println("NO "+usrToCheck);
            if (clientMessage.toUpperCase().startsWith("ISAWAY")) {
                String usrToCheck = clientMessage.substring(6).trim();
                if (isUserAway(usrToCheck)) {
                    sender.println("Z "+usrToCheck);  // is away
                } else {
                    sender.println("X "+usrToCheck);  // not away
            if (clientMessage.toUpperCase().startsWith("CLIENTAWAY")) {
                String usrToCheck = clientMessage.substring(10).trim();
                if (!usrToCheck.trim().equals("")) {
                    setClientAsAway(usrToCheck);
            if (clientMessage.toUpperCase().startsWith("CLIENTBACK")) {
                String usrToCheck = clientMessage.substring(10).trim();
                if (!usrToCheck.trim().equals("")) {
                    setClientAsBack(usrToCheck);
            // Exit the clients connection to the server.
            if (clientMessage.toUpperCase().startsWith("EXIT")) {
                sender.println("GOODBYE");
                this.close();
            if (clientMessage.toUpperCase().startsWith("WHOISONLINE")) {
                whoisOnline();
            if (clientMessage.toUpperCase().startsWith("DISPATCHIM")) {
                String imStr = clientMessage.substring(1).trim();
                String to = imStr.substring(0,imStr.indexOf(" ")).trim();
                String imMsg = imStr.substring(imStr.indexOf(" ")).trim();
                dispatchIM(to,imMsg);  
          }  // end while is connected
        } // End run method
         public synchronized void addIMToQueue(String from, String msg) {
             instantMessage im = new instantMessage(from,msg);
             imQueue.addLast(im);
         private synchronized void getInstantMessages() {
             while (!imQueue.isEmpty()) {
                 instantMessage tmpMsg = imQueue.remove();
                 String tmpHandle = tmpMsg.getHandle();
                 String tmpImMsg = tmpMsg.getMsg();
                 sender.println("L "+tmpHandle+" "+tmpImMsg);
             sender.println("IMPOPDONE");
         private void dispatchIM(String to, String m) {
            for (int i = 0; i < MAX_CONNECTIONS; i++) {
                if (t[i] != null) {
                    if (t.username.trim().equals(to)) {
    pmClientHandler x = t[i];
    PrintStream ps = x.sender;
    ps.println("IMMSG "+this.username+" "+m);
    * Method will relay back to client a list of who's online. When it's finished
    * the command DONELISTING is dispatched.
    private void whoisOnline() {
    for(int i=0; i < MAX_CONNECTIONS; i++) {
    if (t[i] != null && t[i].username.trim() != "")
    sender.println(t[i].username);
    sender.println("DONELISTING"); // so client knows we're done
    } // END whoisOnline METHOD
    private boolean isOnline(String user) {
    boolean isOn = false;
    for (int i = 0; i < MAX_CONNECTIONS; i++) {
    if (t[i] != null && t[i].username.trim().equals(user.trim())) {
    isOn = true; break;
    return isOn;
    private boolean isUserAway(String user) {
    boolean tmpIsAway = false;
    for (int i = 0; i < MAX_CONNECTIONS; i++) {
    if (t[i] != null) {
    if (t[i].username.trim().equals(user)) {
    if (t[i].userAway) {
    tmpIsAway = true;
    break;
    } else {
    break;
    return tmpIsAway;
    private void setClientAsAway(String user) {
    //this.userAway = true;
    for (int i = 0; i < MAX_CONNECTIONS; i++) {
    if (t[i] != null) {
    if (t[i].username.trim().equals(user)) {
    t[i].userAway = true;
    private void setClientAsBack(String user) {
    //this.userAway = false;
    //this.userBusy = false;
    //this.userInvisible = false;
    for (int i = 0; i < MAX_CONNECTIONS; i++) {
    if (t[i] != null) {
    if (t[i].username.trim().equals(user)) {
    t[i].userAway = false;
    t[i].userBusy = false;
    t[i].userInvisible = false;
    private boolean isUserBusy(String user) {
    boolean tmpIsBusy = false;
    for (int i = 0; i < MAX_CONNECTIONS; i++) {
    if (t[i] != null) {
    if (t[i].username.trim().equals(user)) {
    if (t[i].userBusy) {
    tmpIsBusy = true;
    break;
    } else {
    break;
    return tmpIsBusy;
    private boolean isUserInvisible(String user) {
    boolean tmpIsInvisible = false;
    for (int i = 0; i < MAX_CONNECTIONS; i++) {
    if (t[i] != null) {
    if (t[i].username.trim().equals(user)) {
    if (t[i].userInvisible) {
    tmpIsInvisible = true;
    break;
    } else {
    break;
    return tmpIsInvisible;
    * Method will close the connection to the server.
    * It will also free up array location for any new connections
    private void close() {
    if (isConnected) {
    try {
    connection.close();
    isConnected = false;
    userValidated = false;
    System.out.println("User " + username + " has disconnected from the Pita Messenger server.");
    for(int i=0; i < MAX_CONNECTIONS; i++)
    if (t[i]==this) t[i]=null; // set array element to null so we can accept another
    // connection had we been maxed out
    } catch (IOException e) { }
    } // end pmClientHandler class
    Now finally for my problem...this all works EXACTLY as expected when I telnet to the server. My client GUI application has an issue though. When I want to send an IM to a particular user...the thread code above that listens for *DISPATCHIM* get's who the IM is to and what the message is in the following protocol format *DISPATCHIM to msg* and call the following private method:private void dispatchIM(String to, String m) {
    for (int i = 0; i < MAX_CONNECTIONS; i++) {
    if (t[i] != null) {
    if (t[i].username.trim().equals(to)) {
    pmClientHandler x = t[i];
    PrintStream ps = x.sender;
    ps.println("IMMSG "+this.username+" "+m);
    Basically, if not obvious, what I'm doing here is iterating through the array of client connection threads and finding the client thread that belongs who this message is to, and accessing the sender object and dispatching to the IM to that client. Again, all works perfectly in telnet. However, my client GUI is not recieving any data. With all my testing, it seems that I am only able to access and modify strings and boolean variables, however it's like I've lost the sender object (only in my GUI app). This is really bugging the hell out of me and I've spent days trying to figure this out. Something is just not right. My client app has a dispatcher thread that constantly listens for incoming connects (if a buddy is online, or an instant message). This is the run method of that class:public void run() {
    String data;
    while(true) {
    try {
    try {
    data = reciever.nextLine();
    if (!data.trim().toUpperCase().startsWith("YES") && !data.trim().toUpperCase().startsWith("NO") && !data.trim().toUpperCase().startsWith("X") && !data.trim().toUpperCase().startsWith("Z")) {
    System.out.println("Foreign command: "+data);
    } catch (Exception e) { System.out.println("ERR: "+e); break; }
    // pass any data returned at any time during to the serverListener method
    serverListener(data);
    } catch (Exception e) { }
    * Method is used to handle all incoming messages from the server.
    private void serverListener(String data) {
    if (data.trim().toUpperCase().startsWith("IMMSG")) {   // Handle incoming im
    String imStr = data.substring(1).trim();
    String imFrom = imStr.substring(0,imStr.indexOf(" ")).trim();
    String imMsg = imStr.substring(imStr.indexOf(" ")).trim();
    // Check to see if we have any IM sessions open already
    if (isChatWithBuddyOpen(imFrom)) {
    imWindow thisIMSession = getIMSession(imFrom);
    thisIMSession.appendBuddyMessage(imMsg);
    thisIMSession.setVisible(true);
    } else {
    newIMSession(imFrom);
    imWindow thisIMSession = getIMSession(imFrom);
    thisIMSession.appendBuddyMessage(imMsg);
    thisIMSession.setVisible(true);
    // Garbage collection for old IM sessions
    if (!imSessions.isEmpty()) {
    for (int i = 0; i < imSessions.size(); i++) {
    imWindow isGarbageIM = imSessions.get(i);
    if (isGarbageIM == null || isGarbageIM.chatBuddy.trim().equals("")) {
    imSessions.remove(i);
    } else if (data.trim().toUpperCase().startsWith("Z")) {  // Handle user is away response
    String userResponse = data.substring(1).trim();
    clientGUI.handleUserAwayMsg(userResponse, true);
    } else if (data.trim().toUpperCase().startsWith("X")) {  // Handle user is online response
    String userResponse = data.substring(1).trim();
    clientGUI.handleUserAwayMsg(userResponse, false);
    } else if (data.trim().toUpperCase().startsWith("ISBUSY")) { // Handle user is busy response
    } else if (data.trim().toUpperCase().startsWith("NOTBUSY")) { // Handle user is not busy
    } else if (data.trim().toUpperCase().startsWith("ISINVISIBLE")) { // Handle user is invisible
    } else if (data.trim().toUpperCase().startsWith("NOTINVISIBLE")) { // Handle user is  not invisible
    } else if (data.trim().toUpperCase().startsWith("YES")) {  // Handle user is online
    String userResponse = data.substring(3).trim();
    clientGUI.handleUserOnlineMsg(true,userResponse);
    } else if (data.trim().toUpperCase().startsWith("NO")) {  // Handle user is offline
    String userResponse = data.substring(3).trim();
    clientGUI.handleUserOnlineMsg(false,userResponse);
    } // end serverListener method
    It's like my receiver object gets NOTHING. Again, this only occurs with my GUI app, in telnet. Can anyone PLEASE advise as to what might be occuring. Thanks very much. If you might really be able to help I could post the entire app and server zipped up so that you can poke through. If you help me figure this out and I understand why it's not working, I'll buy you a case of your favorite beer ;) Thanks!                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                

    A couple of things.
    In future Networking related questions should be posted into the Networking forum.
    There is too much code here and too much page width. It's a bit overwhelming. You'll need to narrow this down a bit. From looking so far I see some potential
    portocol related issues. Like the readLine. Are you sure you are always writing line breaks on the other side? And then there's the substring bits which are
    going to be brittle.
    My suiggestion would be to trace things through and be able to point out exactly where the code is getting stuck/failing. Even getting it narrowed down to a method
    would be very helpful.

  • Is there a socket connetion avalible for java mobile?

    i use forte mobile edition and i don't seem to have socket connection in my import am i missing an api or is there an alternative? thanks in advance

    hehe never mind i think i got it (im new at thi :P) Connector will do the trink io think

  • Socket reconnection issue

    Hi,
    our aim of using the sockets is to send the HL7-message to HL7-engine.
    while reconnecting to the engine(server) i am following the steps
    1. close the outputstream of the socket
    ( socket.getOutputStream().close() )
    2. close the socket
    ( socket.close() )
    3. wait for 2 minutes and
    4. create the socket and connect to engine
    imedxORUChannel = new Socket();
    imedxORUChannel.connect(new InetSocketAddress(getREMOTEHOST(), getREMOTEPORT()));
    5. sometimes client socket is getting connected to server , sometimes not.
    i want the socket to connect to remote host with in small span of time.
    can any one provide the solution for this.
    thanks in advance .

    while reconnecting to the engine(server) i am following the steps
    1. close the outputstream of the socket
    ( socket.getOutputStream().close() )
    2. close the socket
    ( socket.close() )Unnecessary if you've closed the output stream.
    3. wait for 2 minutes and Why?
    5. sometimes client socket is getting connected to server , sometimes not.What exception is thrown when it fails? Show the complete exception text.
    i want the socket to connect to remote host with in small span of time.It should connect within seconds, or fail after not more than about 75 seconds. You can reduce that timeout by calling the connect() method that takes a timeout parameter.

  • Airplay does not recognise my Pioneer vsx-1122-k on my iPad, I can control my receiver via the pioneer app on my iPad so it is just airplay not a connetivity issue.  My Panasonic Stereo is recognised on Airplay.

    Since upgrading to the latest IOS, Airplay does not recognise my Pioneer vsx-1122-k on my iPad, I can control my receiver via the pioneer app on my iPad so it is just airplay not a connectivity issue.  My Panasonic Stereo is recognised on Airplay.

    Hi
    I don't know if you're still having this issue but there is a way round it as I'm having the same troubles.
    I've just spoken to Apple about it and found out:
    – If you have a Mac made before Mid-2011, it doesn't have a piece of hardware needed to take advantage of the 'Airplay mirroring'
    – So you can update to a later version 10.6.8+ but this won't help at all
    The way round it:
    – Download 'Airfoil' and install this
    – You can then play music from any defined source (Spotify, Quicktime etc) through your Airplay connected speakers
    So sadly, for those have a Mac from before Mid-2011 there's isn't an option that's as easy as Option-click on the sound icon to switch to Airplay speakers.
    Hope that helps, I can now get on with the rest of my day now after sorting this out.
    Adam

  • Bent Pins - CPU socket -Warranty Issue

    Good day,
    I hope this forum and it's experts can shed some light on a problem we have.
    The situation:
    We bought a Socket 1150 H81M-P32L Motherboard with power supply and CPU (with heat-sink & fan), the previous board died.
    We installed the CPU, then the motherboard and power supply, tested all,ok.
    The PC ran fir two days, no problem. Upon the 3rd day the PC was down, tried restarting but no power.
    Investigated, tested the power supply-ok, the board was dead, no lights on board, no posting, dead, like a doornail.
    We removed the board as is and took it to the supplier, they tested, still dead, removed the CPU and said there was bent pins on the CPU socket and they will not replace under warranty, and this is where the problem comes in.
    Maybe the experts can tell me if:
    The pins was bent from the getgo, will/could it have worked for two days?
    The pins is bent will it cause the board to be completely dead?
    (-see attached photos)
    Please enlighted us with your thoughts and expert advice

    Un-hid your attachments so everyone can see them now.
    Is it possible? Sure, I would definitely say that it is possible.
    Is it likely to happen? No, I would say it generally is not likely to happen.
    The CPU sockets are very fragile now. And those pins can very easily become bent. I would wager that installing the CPU is probably the most important part of building a PC anymore.
    That being said, there probably isn't a whole lot that you can do about it. You could try and do an RMA with MSI, but I'm honestly not sure how well that will go.
    >>How to contact MSI.<<

  • Windows 7 ipod touch 1st gen conneting issues

    I just got a new Lenovo G550 with windows 7, and whenever i try to connect my ipod touch 1st generation to the computer I here the connecting "ding-dung" but my ipod doesn't charge or isn't recognized by itunes.

    Sounds like something came loose or exposed. From what i read, it looks like your battery is losing it's charge quickly. My advice would be to take it in to a local apple store and see if they can fix it or run a diagnostic. Unfortunately, if i had to guess i'd say there's a hardware problem since your battery is dying so fast and is having charging problems. Good luck.

  • USB connetion issues

    I have a Canon SX50 HS and it has stopped connecting to my laptop. I have changed the USB cable. Any suggestions

    I have tried it on a netbook and it connected normally.
    The problem I have is with a Toshiba Satellite L350-21T on which I keep all my photos and Photoshop Elements. It runs Windows 7. It was working fine up until 6 weeks ago so I am puzzled. It recoginses a memory stick in the port just fine. I have checked the devices through Control Panel and there are no problems reported on the USB ports. I have rebooted the laptop and the problem persists. The camera battery is fully charged.
    I have had to download the photos on to the netbook and use Dropbox to transfer them.

  • Socket communication failure between Java applet and C++ application

    I have a java applet that connects to a C++ application via Java's ServerSocket and Socket objects. THe C++ application is using the Winsock 2 API. The applet and application are running on an NT workstation (SP 6) and using IE (5.5) For a very simple C++ test applications the communictions work fine. Once more code gets added to the C++ application the portion of the socket that C++ listens to seems to close. Upon performing a recv call the return value is a zero. Microsoft insists this is a sign the Java side has shut down the socket. The Java applet can still receive messages from the C++ app but C++ cannot receive responses from the Java side. Java throws no exceptions and an explicit check of the socket shows no errors. Again, what puzzles me is that it works for simple C++ applications. Are there any known conflicts between Java and C++ in this regard?
    I have inlcuded the basic java code segments below.
    / run Method.
      * This method is called by the Thread.start() method. This
      * method is required for the implementation of the Runnable interface
      * This method sets up the server side socket communication and
      * contiuously loops looking for requests from a external
      * socket.
      * @author Chris Duke
      public void run(){
         // create socket connections
         boolean success = false;
         try {
             cServerSocket = new ServerSocket(cPortID);
             System.out.println("Waiting for client to connect...");
             cClientSocket = cServerSocket.accept();
             System.out.println("Client connected");
             // Create a stream to read from the client
             cInStream = new BufferedReader(new InputStreamReader(
               cClientSocket.getInputStream()));
             // Create a stream to write to the client       
             cOutStream = new PrintWriter(
               cClientSocket.getOutputStream(), true);
             success = true;
         }catch (IOException e) {
             System.out.println("CommSocket:Run - Socket Exception(1) " + e);
             success = false;
         // if the socket was successfully created, keep the thread running
         while (success){
             try{
                // check socket to see if it is still available for reading
                if (cInStream != null && cInStream.ready()){
                    // check for an incoming message
                    String message = ReceiveMessage();
                    // Send message to listeners
                    Event(message);
                if (cInStream == null){
                    success = false;
                    System.out.println("CommSocket:Run - shutdown");
             }catch (IOException e){
                System.out.println("CommSocket:Run - Socket not ready exception");
                break;
    // SendMessage method -
      *  Sends a text message to a connected listener through port specified by portID
      * @author Chris Duke
      * @param  String message - This will be the message sent out through the server
      * socket's port specified by portID.
       public void SendMessage(String message){
          cOutStream.println(message);
          if (cOutStream.checkError() == true)
            System.out.println("SendMessage : Flush = Error");
          else{
            System.out.println("SendMessage : Flush - No Error");
       }

    a very simple C++ test applications the communictions work fine. Once more code gets added to the C++ application the portion of the socket that C++ listens to seems to close.
    This quite strongly implicates the extra code in the C++ App. The firstly thing I would try would be telnet. Try connecting to both versions of the C++ Application and manually reproducing a proper exchange.
    a recv call the return value is a zero. Microsoft insists this is a sign the Java side has shut down the socket.
    A correct implementation of recv should return the number of bytes received, or -1 for an error. A zero return indicates no bytes received not a socket closed/error. This sounds like FUD to me.
    Are there any known conflicts between Java and C++ in this regard?
    I can see no obvious faults, though the code is incomplete, I don't think it's an sockets implementation issue, at either end, it sounds more likely to be a protocol/handshaking bug in the C++ App.

  • Socket programming usin nio package

    hello frens i m new to socket programming
    i come to know that nio packaage provides more sophisticated and efficient API to deal with socket programming issue
    I need to know where i can get tutorial about socket programming using nio pacakage

    Try google
    http://www.google.co.uk/search?q=java+nio+tutorial

  • Oracle OCI performance

    Hi all,
    We would like to find out which setup gives us which performance, so we can pick the best
    for various circumstances. But first we need to establish some facts:
    Our previous setup:
    - HPUX11, Oracle 7.3 / 8.1.7, C++, oci 7.3 / oci 8 as contained in the oracle installation
    There was a slowdown between OCI for 7.3 and OCI for 8.1.7. This forced us to use the 7.3
    protocol against our 8.1.7 database.
    When we used the OCI driver with C++
    on previous projects the Oracle process said (LOCAL=YES) and was a child process of the
    application it served. We'd like to get this effect back
    Our current setup:
    - HPUX11, Oracle 9.0.1 / 9.1, java 1.3.1, oracle12.zip/ocijdbc9.sl as contained in the oracle
    installation. The database and the applications will run on the same machine. Clients will
    not do any direct database access.
    Question that arose. We need to answer these both theoretically and practically.
    1. Is the 'oci8' driver faster than the 'thin' driver ? (preliminary tests showed the opposite)
    2. Is there an OCI 7.3 version of the JDBC OCI driver available? (this was faster than oci8, see above)
    3. Can the thin driver use tnsnames.ora instead of host:port:sid ?
    4. Can the thin driver connect to the database by something other than a tcp-socket-connection?
    When we use the thin driver the Oracle-Process, that is spawned to handle the request,
    says (LOCAL=NO) and its parent is process 1 (init). We'd like again local child process, see above)
    5. How can we get the oci8 driver to use something other than a tcp-socket-connetion?
    6. What's the correct syntax for the beq-protocol or is that (as I heard) not available for hpux?
    7. What's the correct syntax/setup for IPC/TCP-Loopback and what are their advantages/disadvantages?
    8. Is it at all possible to expect the java application to talk to it's server process using shared
    memory and IPC instead of TCP-sockets?
    9. What other considerations are possible to generically speed up JDBC, as this seems to take up
    the bulk of our processing time. We do use bulk fetches and Oracle-bulk updates. When we
    activate Oracle-Tracing and analyze the results the times are negligible when compared to the
    total JDBC time as measured in the application (factor 1 to 10 or so).
    regards,
    Frieder Schenke

    I can't help you on the HP issues, but have you tried bumping up the FetchSize for ResultSets returning large numbers or rows?
    I have seen favorable performance increases with the "thin" driver on this.
    -Peter

  • What is the easiest way to open an application from Labview?

    I need to open an application from labview and depending on a user's selection, load one out of a group of files for the application that is opened. I need to know what is the best or easiest way to open an application and load a file that is used by the application based on a selection.

    Here is the response that I got from Cognex when I asked them about how to do this. Do you understand what they are talking about?
    In order to do something like this you will probably want to look into the Display Control/SDK for In-Sight. The Display Control gets installed along with In-Sight Explorer and includes a control that can be used in an environment like Labview to communicate with In-Sight sensors while the SDK is an enhanced version of the Display Control that gives you more control and functionality. I am not very familiar with the Labview environment so I will give some code snippets in VB.Net and hopefully you can adjust them as necessary. Specifically I see 3 possible avenues to do this:
     1) Using the Display Control you have access to many of the dialog boxes that are used in In-Sight Explorer including the Load Job dialog box. You can spawn this dialog box through a line of code similar to cvsInSightDisplay1.Edit.OpenJob.Execute(). I am not certain if the Labview environment will be able to spawn and display this dialog though. 2) With the addition of the SDK (additional purchase) you can directly access sensor properties including the job. There is a method called LoadJobFile to load jobs from on the sensor and LoadJobFileLocally to load jobs from the host machine. A typical line of code might be cvsInSightDisplay1.InSight.File.LoadJobFile("myjob1.job").3) If Labview cannot handle the dialogs and the SDK is not an option for you then you may still be able to do this using Native Mode commands. Native Mode commands are sent through a socket on the telnet port (typically port 23). Keep in mind that you will need to handle the username/password prompt and response when you first open the socket before issuing any Native Mode commands. The command to load a job file from the sensor would be the Load File command which would be a string similar to "LF myjob1.job". The Native Mode commands are documented in the In-Sight Explorer help file. 

  • Adobe Form Error: Invalid Response Code: (401) Unauthorized. The request...

    When trying to run an Adobe Form webdynpro app, I am receiving the following error:
    <b>Invalid Response Code: (401) Unauthorized. The requested URL was:"http://localhost:50000/AdobeDocumentServices/Config?style=document"</b>
    I have checked the ADS test at <server:port>/AdobeDocumentServices/Config; the test did return the version number.
    <i><b>Does anyone have any other ideas of what I should check?</b></i>
    Also, why is it running a url with "localhost" in it?  If this is running on the java was server, then I guess that could make sense.  But if the url request is requesting something from localhost, isn't that my computer?  I guess it depends on if this is a server request or a client request.  I hope this is a server request.

    Sumit -
    First, I think config is okay.  I can run the web service under my id okay.
    Second, I am not sure what the impact is having the build done locally.
    I am building and deploying locally in NWDS to my local portal. But then I am sending the EAR file to the system admin to deploy to my dev server (I am doing this because they will not give out the SDM password.  And, I am waiting on the NWDI setup to be complete; when that is complete I will let NWDI deploy to the dev portal.)
    Incidentally, I am receiving this error on the dev server, not my local portal. (I have tried running on my local portal, but I am getting a socket timeout error. But this is interesting, because I <i>can</i> run other webdynpro non-Adobe apps. I am not tracking down this error at this point because I am really just interested in the dev server.  If I get past the 401 error on the dev server, and then get the socket timout issue...then I will worry about it.)

Maybe you are looking for