Multi-threaded performance server using 2 ports to two-way communication

Hi, I'm new in the forums so welcome everyone. I'm developing now an online computer game based on orginal Polish board-game, but it doesn't mean. Important is that I need to develope a high-performance multi-threaded server, which can serve... let's say few hundres of games, and a thousend of players simulateously. My server works on two ports/sockets.
First one is represented by "ServerSocketChannel clientConSsc" in my code. The main thread in my server class which invokes the method "run()" (which You can see below), registers clientConSsc with Selector and then repeatingly accepts incoming connections from clients on this socket. When connection(channel) is estabilished and clients wants to write some request to this channel, the main thread on server creates a new instance of class "RequestHandler" which extends Thread and handles this request (reads the request from channel, makes some changes on server, spreads some new messages to other clients in the same game and so on... everything on the same socket/port/channel). Then the channel/connection is closed by the server - I call such connections: "a short connections". In the same time the main thread continues the loop and is still able to accept connections from another players. That's the idea of multi-threaded server, right? :) And to this point, everything works fine, but... what if the server wants to trigger some new command, write new information to client?
Server could have tried to open a SocketChannel to client's IP address, but then the client programme would have to create and ServerSocketChannel object, bind it to some InetAddress and then... and then client becomes a server! - that breaks the idea of client-server cooperation and demands on players of my game to have routed some port on their machines. To resolve this problem I made some sort of "system" which, when some player/client is logging into my server, accepts second (this time constant, not "short") connection on the second port I mentoined on the beginning. This connection is held in variable "SocketChannel serverCon" of class "Player" - which reflects a player logged onto server. Server maintains every such connection till the client logs off. After the connection is accepted, the player whom connection it was is added to collection called "playersToRegisterToWrite". After the Selector.selectNow() is invoked (as You can see in the code below), each and every player's connection is registered in selector (with selection key - OP_WRITE and attachment pointing on owning player). In the same time client's code is trying to read some bytes from this connection and blocks on it until some bytes are written to this connection. When server wants to "tell" something to client, deliver some message/command, it creates a new instance of class which extends an abstract class called "ServerAction" (another new thread) and adds it to collection "actionsToDo". In ServerAction's method "run()" there are whole code to interact with client (e.g. send an update of players' list, an update of games' list, a chat message). Finnaly when Selector informs the server that some connection is writable (some client is waiting for commands), then server checks if there's any "actionToDo" involving this client/player. If there is, it unregisters the connection from Selector (so no other ServerAction (thread) can write on this connection) and starts the action. At the end of every "run()" method of subclass of ServerAction there's a code, which again adds the player to collection "playersToRegisterToWrite", so the player's connection can again be registered in Selector and the player can again receive informations from server - after it consumed THIS "ServerAction".
It looks to me like it should be working fine, but it's not. When I test my server and clients on the same machine (no ping/latency) everything seems to be working fine. But when it comes to play my game with somebody even on LAN or through the Internet there comes the problems. My first socket I describe (and first type of connections - short connections) works perfectly fine, so the requests triggered by client are delivered and handled properly. But the second socket is cirppling. For example: the server triggers a command refering to an update of clients logged to server' list. It is triggered by Selector so the client should be ready to read data from server, so the server sends data! And the client never receives it... Why?
It experimented a whole lot of time on SocketChannel's method "configureBlocking(boolean)", but it never helps. I think the client should always block it's listening thread on connection, contratry to server which is ment to be fast, so it should send the data through non-blocking channels. Am I right? Are there any rules refering blocking configuration of SocketChannels?
I will be grateful for every answer. To help You out I attach also drafts from run()'s methods of my classes.
Server's main method - main thread :
    public void run() {
       try {
            selector = Selector.open();
            clientConSsc.configureBlocking(false);
            clientConSsc.register(selector , SelectionKey.OP_ACCEPT);
            while(serverRunning) {
                try {
                    selector.selectNow();
                    Iterator it;
                    synchronized(playersToRegisterToWrite) {
                        it = playersToRegisterToWrite.iterator();
                        while(it.hasNext()) {
                            Player player = (Player)it.next();
                            it.remove();
                            player.serverCon.configureBlocking(false);
                            player.serverCon.register(selector , SelectionKey.OP_WRITE , player);
                    Set keys = selector.selectedKeys() {
                    it = keys.iterator();
                    while(it.hasNext()) {
                        SelectionKey key = (SelectionKey)it.next();
                        if(key.isAcceptable()) {
                            it.remove();
                            clientCon = clientConSsc.accept();
                            clientCon.configureBlocking(false);
                            clientCon.register(selector , SelectionKey.OP_READ);
                            continue;
                        if(key.isReadable()) {
                            it.remove();
                            key.cancel();
                            new RequestHandler(this , (SocketChannel)key.channel()).start();
                            continue;
                        if(key.isWritable()) {
                            if(key.attachment() != null ) {
                                ServerAction action = null;
                                synchronized(actionsToDo) {
                                    Iterator aIt = actionsToDo.iterator();
                                    while(aIt.hasNext()) {
                                        ServerAction temp = (ServerAction)aIt.next();
                                        if(temp.getPlayer().equals((Player)key.attachment())) {
                                            action = temp;
                                            aIt.remove();
                                            break;
                                if(action != null) {
                                    key.channel().configureBlocking(false);
                                    it.remove();
                                    key.cancel();
                                    action.start();
                            continue;
                } catch(Exception e) {
                    statusArea.append(e.toString() + "\n");
                    e.printStackTrace();
                    continue;
        } catch(ClosedChannelException e) {
            statusArea.append(e.toString() + "\n");
        } catch(IOException e) {
            statusArea.append(e.toString() + "\n");
            A part of server's RequestHandler's class' method run() - the method which handles requests triggered by client on first port:
public void run() {
        boolean served = false;
            try {
                channel.configureBlocking(true);
                retryCount++;
                retry = false;
                String command = ns.readText(channel).trim();
                ns.statusArea.append("ktos przesyla komende: " + command + "\n");
                if(command != null && !command.equals("ERROR")) {
                    String[] cmd = command.split("�");
                    ns.statusArea.append("komenda: " + cmd[0] + "\n");
                    if(cmd[0].equals("CHAT")) {
                        if(cmd.length != 5) {
                            retry();
                        } else {
                            if(cmd[2].equals("NOGAME")) {      // jezeli nie ma okreslonej gry czyli rozsylamy do wszystkich
                                for(int i = 0 ; i < ns.loggedPlayersListItems.size() ; i++) {
                                    Player current = (Player)ns.loggedPlayersListItems.get(i);
                                    if(current.state == Player.CHOOSING && !current.equals(new Player(Integer.parseInt(cmd[1]))))   // jezeli gracz jest w okienku wybierania gry to wysylamy mu broadcast
                                        ns.actionsToDo.add(new SendMsg(ns , current , "CHAT�" + cmd[1] + "�" + cmd[3] + "�" + cmd[4]));
                            } else {
                                Game game = (Game)ns.gamesListItems.get(ns.gamesListItems.indexOf(new Game(Integer.parseInt(cmd[2]))));
                                for(int i = 0 ; i < game.players.size() ; i++) {
                                    Player current = (Player)game.players.get(i);
                                    if(!current.equals(new Player(Integer.parseInt(cmd[1]))))
                                        ns.actionsToDo.add(new SendMsg(ns , current , "CHAT�" + cmd[1] + "�" + cmd[3] + "�" + cmd[4]));
                            served = true;
                    } else if(cmd[0].equals("GETGAMEINFO")) {
                        if(cmd.length != 3)
                            retry();
                        else {
                            int gameID = Integer.parseInt(cmd[2]);
                            ns.statusArea.append("poproszono o informacje o grze nr: " + gameID + "\n");
                            Game checkedGame = new Game(gameID);
                            if(ns.gamesListItems.contains(checkedGame)) {
                                Game game = (Game)ns.gamesListItems.get(ns.gamesListItems.indexOf(checkedGame));
                                channel.configureBlocking(true);
                                ObjectOutputStream oos = new ObjectOutputStream(channel.socket().getOutputStream());
                                oos.writeObject(game);
                                oos.writeObject(game.players);
                                oos.flush();
                                ns.statusArea.append("wyslano informacje o grze nr: " + gameID + "\n");
                            } else {
                                ns.statusArea.append("brak gry o nr: " + gameID + "\n");
                            served = true;
            } catch(IOException e) {
                e.printStackTrace();
        if(!served) {
            ns.findAndDisconnectPlayer(channel);
        try {
            channel.close();
        } catch(IOException e) {
            e.printStackTrace();
    }An example of ServerAction's subclass - the class which triggers server commands to client on second port:
class UpdateLoggedPlayersList extends ServerAction {
    public UpdateLoggedPlayersList(NeuroServer ns , Player player) {
        super(ns , player);
    public void run() {
        try {
            serverCon.configureBlocking(true);
            ns.sendText("UPDATELOGGEDPLAYERSLIST" , serverCon);
            if(ns.readText(serverCon).equals("OK")) {
                ObjectOutputStream oos = new ObjectOutputStream(serverCon.socket().getOutputStream());
                oos.writeObject(ns.loggedPlayersListItems);
                oos.flush();
            synchronized(ns.playersToRegisterToWrite) {
                 ns.playersToRegisterToWrite.add(player);
        } catch(IOException e) {
            e.printStackTrace();
}A part of client's CmdHandler's class' method run() - the method which handles commands triggered by server:
public void run() {
    try {
        while(works) {
            String command = nc.readText(nc.serverCon);
            System.out.println("Server przesyla komende: " + command + "\n");
            String[] cmd = command.split("�");
            if(cmd[0] != null && !cmd[0].equals("ERROR")) {
                if(cmd[0].equals("CHAT")) {
                    if(nc.chooseGameDialog != null && nc.chooseGameDialog.isVisible()) {     // jezeli na wybieraniu gry
                        newChatEntry(cmd[2] , null , cmd[3] , nc.chooseGameDialog.chatPane);
                    } else if(nc.readyDialog != null && nc.readyDialog.isVisible()) {  // jesli na przygotowywaniu
                        Player sender = (Player)nc.actGame.players.get(nc.actGame.players.indexOf(new Player(Integer.parseInt(cmd[1]))));
                        newChatEntry(cmd[2] , sender.fraction , cmd[3] , nc.readyDialog.chatPane);
                    } else if(nc.ng != null) {                   // jesli w grze
                        Player sender = (Player)nc.actGame.players.get(nc.actGame.players.indexOf(new Player(Integer.parseInt(cmd[1]))));
                        newChatEntry(cmd[2] , sender.fraction , cmd[3] , nc.ng.inGameChatPane);
                } else if(cmd[0].equals("UPDATELOGGEDPLAYERSLIST")) {
                    nc.sendText("OK" , nc.serverCon , false);
                    nc.serverCon.configureBlocking(true);
                    ObjectInputStream ois = new ObjectInputStream(nc.serverCon.socket().getInputStream());
                    DefaultListModel players = (DefaultListModel)ois.readObject();
                    nc.chooseGameDialog.updateLoggedPlayersList(players);
    } catch(IndexOutOfBoundsException e) {
        System.out.println(e);
    } catch(IOException e) {
        System.out.println(e);
    } catch(ClassNotFoundException e) {
        System.out.println(e);
}And two methods I used in codes above: sendText(String text , SocketChannel sc) and readText(SocketChannel sc) - they are my "utility" methods, which I use to send and receive Strings through specified SocketChannels.
boolean sendText(String text , SocketChannel sc) {
    ByteBuffer bbuf = ByteBuffer.allocate(BSIZE);
    boolean sendRetry;
    boolean sent = false;
    do {
        sendRetry = false;
        try {
            StringBuffer cmd = new StringBuffer();
            cmd.setLength(0);
            if(text.length()+4 < 100)
                cmd.append("0");
            if(text.length()+4 < 10)
                cmd.append("0");
            cmd.append(Integer.toString(text.length()+4) + "�");
            cmd.append(text);
            cmd.append("\n");
            bbuf = charset.encode(CharBuffer.wrap(cmd));
            sc.write(bbuf);
            bbuf.clear();
            int n = sc.read(bbuf);
            if(n == 1) {
                bbuf.flip();
                Byte re = bbuf.get();
                if(re == 1) {
                    sendRetry = true;
                } else {
                    sent = true;
        } catch(Exception e) {
            findAndDisconnectPlayer(sc);
            try {
                sc.close();
            } catch(IOException f) {
                f.printStackTrace();
            return false;
    } while(!sent && sendRetry);
    return true;
String readText(SocketChannel sc) {
    ByteBuffer bbuf = ByteBuffer.allocate(BSIZE);
    int readRetryCount = -1;
    boolean readRetry;
    do {
        readRetry = false;
        readRetryCount++;
        StringBuffer cmd = new StringBuffer();
        cmd.setLength(0);
        bbuf.clear();
        try {
            readLoop:
            while(true) {
                int n = sc.read(bbuf);
                if(n > 0) {
                    bbuf.flip();
                    CharBuffer cbuf = charset.decode(bbuf);
                    while(cbuf.hasRemaining()) {
                        char c = cbuf.get();
                        if(c == '\r' || c == '\n') break readLoop;
                        cmd.append(c);
                } else break;
            statusArea.append(Thread.currentThread().getId() + " readText() odczytuje: " + cmd.toString() + "\n");
            if(cmd.length() < 3 || Integer.parseInt(cmd.substring(0 , 3)) != cmd.length()) {
                sc.write(ByteBuffer.wrap(new byte[] {1}));
                readRetry = true;
            } else {
                sc.write(ByteBuffer.wrap(new byte[] {0}));    // length OK
                return cmd.toString().substring(4 , cmd.toString().length());
        } catch(Exception e) {
            findAndDisconnectPlayer(sc);
            try {
                sc.close();
            } catch(IOException f) {
                f.printStackTrace();
            return "ERROR";
    } while(readRetry && readRetryCount < 3);
    findAndDisconnectPlayer(sc);
    try {
        sc.close();
    } catch(IOException e) {
        e.printStackTrace();
    return "ERROR";
}Edited by: Kakalec on Jul 23, 2008 11:04 AM

You seem to be using a horrendous mixture of PrintWriters, BufferedReaders, ObjectOutputStreams, and no doubt ObjectInputStreams. You can't do that.
Some rules about this:
(a) Whenever you use a stream or reader or writer on a socket, you must allocate it once for the life of the socket, not every time you want to do an I/O.
There are many reasons for this including losing buffered data in the old stream and auto-closure of the socket on garbage-collection of the old stream.
(b) You can't mix stream types on the same socket. (i) If you're writing objects, use an ObjectOutputStream, you must read with an ObjectInputStream, and you can't read or write anything that isn't supported by the API of ObjectOutputStream. (ii) If you're writing lines, use a BufferedWriter and a BufferedReader at the other end. If you're writing characters, use a Writer and a Reader. (iii) If you're writing primitive data or UTF strings, use a DataOutputStream and a DataInputStream. (iv) If you're writing bytes, use DataOutputStream and a DataInputStream or an OutputStream and an InputStream. You can't mix (i), (ii), (iii), and (iv).
(c) Don't use PrintWriter or PrintStream over the network. They swallow exceptions that you need to know about. They are for writing to the console, or log files, where you don't really care about exceptions.
(d) Call flush() before reading.
(e) Always close the 'outermost' output stream or writer of a socket, never the input stream or the socket itself. Closing any of these closes the socket and therefore makes the other stream unusable, but only closing the output stream/writer will flush it.

Similar Messages

  • Issue with publishing schema as webservice using WCF-BasicHTTP two way channel

    Here is my scenario:
    I am trying to publish a Req-Resp schema which will be consumed by an orchestration and will return a response to me .When I invoke the WCF service end point it triggers the orchestration but the response never comes back to the SOAP UI. My orchestration
    is completing and returning the response.
    But in the SOAP UI I am instead getting : <Message>Root element is missing.
    I am using WCF-BasicHTTP two way port. My app pool id under whcih the BT service is hosted  is part of Administrator group on the server
    My config file is as well updated with   <trust level="Full" originUrl="" /> info.
    What could be the reason for failure.

    Hi,
    Did you try checking your orchestration response xml against the schema definition WCF service is expecting to return.
    Regards Pushpendra K Singh

  • Unable to establish two-way communication with the printer

    I have a HP Photosmart B8550 large format printer, but failed recently to print the whole page, but only one third of the page.  The OS is Window 7 in my commuter.  I downloaded the driver from HP website, but it is not working.  The result of the failure is "The computer is unable to establish two-way communication with the device."  One of the reasons I guess is that I failed to register my printer because I had no way to finish the registration, because there is no further process even if I put my printer name or number into the required block.  Anyhow I failed recently to print anything in the printer.  I am seeking the support after a lot of tries.  Thanks. 

    I have two HP computers and two HP Photosmart B8550 printers.  A month ago printers were not working.  I tried in vain in two computers to download new HP software and driver from internet and got the HP Solution for install error - Windows 7.  Based on this Solution on desk, I tried many many times to follow every step, but the result is the same:  Fatal error during the installation.  
    By using other tools like HP Printer Diagnostic Tools, HP Print and Scan Doctor, I failed too because the diagosis or the choices are not accuate.  For example, the printer is disconnected.  It is wrong even if I changed ports and USB calbe again and again.  The control panet can prove that there is communication, but the printer cannot work as directed.  There is no way to test the printing as Doctor requested, saying the computer is unable to establish two-way communication with the device, which is not helpful to go ahead with the solution.  There is no way to register the printer because there is no such a model HP Photosmart B8550 in its list after search.  
    It is even worse that the new window dialogue asked me to find HP Photosmart Essentials in my computer to install it again and again, and I could not concel the request whenever I open my computer.  
    I guess the HP printer software and driver has something wrong in its root design, which leads me to failure in installation so that the computer could not recognize my printer.  In short, the new HP software and driver makes my printer not functional.  
    By the way, my two printers can work internally in printing sample paper and report and two computer are working in perfect condition. 

  • Error message saying "unable to establish two-way communication with device"

    I have an HP C309a printer/scanner/fax. I have recently reconfigured it to work wirelessly instead of via the USB cable, which it does. But if I try to go on to  the HP Solution Centre/Settings/Printer Toobox to clean the printheads, it tells me that this cannot be done because "the computer cannot establish two-way  communication with the device".
    If I plug the USB cable back in, I can clean the printheads fine.
    Does anyone have a way of allowing me to clean the printheads without using the USB cable?
    roger

    Hi rogercorke,
    I believe you can also clean the printhead from the printer control screen. Press the Wrench button from the printer Home screen and then press Tools>Clean Printhead.
    If you need to use this feature wirelessly, try running the HP network diagnostic utility on your wireless setup and see what it says: http://h10025.www1.hp.com/ewfrf/wc/softwareDownloadIndex?cc=us&lc=en&jumpid=ex_r4155/en/hho/ipg/foru...
    Please click the blue Kudos star in the post that helped you. 

  • Question on PI like RFC,import maps,defining two ways communication

    Hi Foks,
    I am new to PI need information on the below issues.
    1.How we can use RFC?
    2.How to define Two way Communication eg:Remote system to ERP vise versa.
    4.How ti transport the dev. object from Dev to Prod.
    5.How we ca create the maps externally and import in PI is there any way we can do it.
    Please help me out
    shankar

    How we can use RFC?
    Import RFC in ESR/IR under IMPORTED OBJECTS that exist under software component in your ESR.
    While importing RFC,you have to give system details from where you will import RFC in PI.
    How ti transport the dev. object from Dev to Prod.
    /people/sravya.talanki2/blog/2005/11/02/overview-of-transition-from-dev-to-qa-in-xi
    /people/sap.india5/blog/2005/11/03/xi-software-logistics-1-sld-preparation
    /people/sap.india5/blog/2005/11/09/xi-software-logistics-ii-overview
    /people/sap.india5/blog/2005/11/28/xi-software-logistics-solution-iii-cms
    thanks
    Nidhi

  • Unable to establish the two way communication with printer j110a

    every thing is ok but during the printing or ink level checking this message displayed "unable to establish the two way communication with printer j110a" please reply soon?

    Hard Reset – While printer is powered ON, pull the power cord from the printer then from the wall. After 30 seconds reconnect power to wall and printer. This will trigger a ‘dirty power up’ and restore the printer to a known good condition (if it is possible). No user settings are lost with a ‘hard reset’. This ‘Hard Reset’ is one of the most powerful tools to use when the printer hardware is not functioning properly! IF NOT RESOLVED, uninstall hp software & reinstall using latest hp software from hp website.
    Although I am working on behalf of HP, I am speaking for myself and not for HP.
    Love Kudos! If you feel my post has helped you please click the White Kudos! Star just below my name : )
    If you feel my answer has fixed your problem please click 'Mark As Solution' and make it easier for others to find help quickly : )
    Happy Troubleshooting : )

  • Computer unable to establish two-way communication to J4580 through Airport Extreme

    I have my J4580 connected to an Airport Extreme base station via usb.  I've installed the printer software on my HP laptop (Vista) and Bonjour recognizes the printer as networked & installed, but when I try to print, i receive an error message "Computer is unable to establish two-way communication with the device" and the printer queue shows an error.  I've attempted to find a solution through the posts, but haven't seen much that seems to apply to J4580.  Any help???  Thanks!

    I came across this similar problem and spent days trying to figure it out. I knew I was close when I tried to start the HPZ12
    service and it kept failing with "unable to find the specified file". I traced it with a process monitor and found that it was looking
    for a registry key that was not present. Specifically:
    HKLM\System\CurrentCosntrolSet\Services\Pml Driver HPZ12\Parameters
    It was looking for the string:
    ServiceDLL which should be set to:
    C:\WINDOWS\system32\HPZipm12.dll (or something similar)
    The unfortunate thing is that no matter how many times you install and uninstall the HP drivers, then don't reset the registry keys
    for the HPZ12 service. In the end, I ended up doing the following:
    1. Uninstall software and reboot
    2. Go through registry editor and delete the PML key (just did a search for all PML occurences)
    3. Deleted the c:\program files\Hewlett-Packard directory
    4. Deleted the c:\program files\HP directory
    5. Deleted the c:\windows\system32\spool\drivers\w32x86\ contents (anything that referred to an HP printer or driver)
    6. Deleted the HKLM\Software\Hewlett-Packard registry key
    7. Rebooted
    8. Reinstalled and everything worked.
    I suggest you backup any registry keys prior to deleting them in case you make a mistake. You can use the Export feature on
    the right-click context menu to save each key you delete, or use some tool to make a backup of your registry prior to making
    these changes. Similarly, for the files, I renamed directories or created backups of their contents.
    Once I reinstalled, I found that there were TONS of new registry keys added that weren't there before. So the real problem is
    with HPs install/uninstall. It doesn't clean up properly and any aborted or failed instalation will leave the drivers in a poor state.

  • The computer is unable to establish a two way communication with the device

    Hi  I am trying to fix a problem for some one else, and I am struggling where to look next. The issue is that we are unable to check the ink levels of a HP Deskjet 1050 printer.  The error message states that the computer is unable to establish a two way communication with the device. After running through the troubleshooting guide about this issue on the HP site with no joy,  I decided that it may be the printer and suggested a replacememnt.  Unfortunately A new HP Envy 5530 was purchased and connected (wirelessly) but the issue remains. I have uninstalled the drivers multiple times, and also disabled any firewall/anti virus software in case this was interfering. I was hoping that some one could point me in the right direction next? None of the other forum posts here (or any google searches) give a solutuon which has fixed the problem.  Thanks

    No I cant. Unable to ping the printer too, not sure if this is possible normally?

  • How do i fix the inability to establish two-way communication between my computer and the printer?

    HP Photosmart 5510 e-All in One Printer B111a
    Windows XP
    Message "The computer is unable to establish two-way communication with the device."
    Installed new printer
    I'm simply trying to get the estimated ink levels.

    Please make a Genius Appointment and take it in for service.

  • Cannot print to my hp 7500. diagnostics says computer cannot establish two-way communication.?

    cannot print to previously functional HP7500 on wireless network card.  All reports from printer say everything is working fine (network card and printer), but computer says it cannot establish two-way communication.  What do I do?

    pcunning, I would recommend running this utility and seeing what it shows - or resolves:
    http://goo.gl/u3jDE
    Let me know!

  • SCTL-NFC1 is a Near Field Communication(NFC)/Radio Frequency Identification(RFID) Reader and Payment Adaptor designed for iPhone/iPod Touch to provide NFC two-way communication,RFID read/write and contactless payment capabilities.

    SCTL-NFC1 is a Near Field Communication(NFC)/Radio Frequency Identification(RFID) Reader and Payment Adaptor designed for iPhone/iPod Touch to provide NFC two-way communication,RFID read/write and contactless payment capabilities.
    commercial applications such as asset tracking, document tracking, healthcare, security and access control.

    We are the manufactuer of the reader

  • Oraclient9i.dll error in multi threaded delphi server application

    I created a multi threaded server application in delphi using oracle9i and indy server components. When I run my application, I am getting an error "oraclient9i.dll" error when executing my SQL statements. I have check communication between my server application and the client application without using oracle and its working fine, its only when I started executing SQL statements when I got this error.
    Can anybody help me with this problem or point me to the right direction on how to resolve this issue.
    thanks

    > I have tried what you suggested. I have created a
    seperate TOracleSession on each thread that I create
    on the OnConnect event however I am having Problems
    using the oraclesession created on the OnExecute
    event. Somehow it is still executing the SQL that I
    have created on the main form where I first opened an
    oraclesession component created on the main form.
    It sounds then like the TOracleSession object in the thread is a copy of the one in the main thread/form.
    > Do you think that It would work if I create an
    instance of the TOracleDatasets and TOracleQuery on
    the OnExecute event and also at the same time create
    my TOracleSession on this event and continue
    processing the data receive from the client server.
    I've never used the Indy components for threading. The default TThread class worked just fine for me.
    What I used to do is define the session and database objects as privates in my new thread class (let's call it TThreadSQL) - which was subclassed from TThread.
    The constructor of this new TThreadSQL class did the following (writing here purely from memory - have not done Delphi for some time now): constructor TThreadSQL.Create( TNSalias, username, password : string );
    // constructor is called with the Oracle session connection details
    begin
      inherited Create; // call the parent class constructor
      CreateOracleSession; // call own private method to create an Oracle connection
    end;
    The CreateOracleSession method would then:
    - create a BDE Session (TSession) object
    - create a BDE Database (TDatabase) object, using the BDE Oracle native driver and an Oracle TNS alias plus username and password for connection
    The destructor would close the connection. The Execute method which is used to fire up the thread, would use a TQuery object (or whatever) to execute a SQL using it owns connection.

  • The problem of profiling a multi-thread flash game  using adobe scout cc

    I have a multi-thread flash game code, it can run perfectly. The main swf creates another swf which will connect to a remote server. I can get profiling information of the main swf  using adobe scout cc, but the problem is that I can't get profiling information of another swf ! The scout complains " can't start a session because the telemetry data isn't valid" for another swf. Although some times, the scout does not complain, the Summary Panel of scout provides information“We encountered an error while processing this session: Some of the data we present may not be correct". And the scout log file shows:
    Log file created: 2014/11/20 15:35:08
    11/20/2014 15:35:08.395 Scout starting up.
    11/20/2014 15:35:08.471 InitDNSService failed
    11/20/2014 15:36:47.055 <2896> <telemetryCore.Query> <1> Incorrect data: Memory category 7 for frame stats query over time interval [100000,200000] is greated than its parent
    11/20/2014 15:36:47.057 <2896> <telemetryCore.Query> <1> Incorrect data: Memory category 7 for frame stats query over time interval [200000,300000] is greated than its parent
    11/20/2014 15:36:47.058 <2896> <telemetryCore.Query> <1> Incorrect data: Memory category 7 for frame stats query over time interval [300000,400000] is greated than its parent
    11/20/2014 15:36:47.058 <2896> <telemetryCore.Query> <1> Incorrect data: Memory category 7 for frame stats query over time interval [400000,500000] is greated than its parent
    11/20/2014 15:36:47.061 <2896> <telemetryCore.Query> <1> Incorrect data: Memory category 7 for frame stats query over time interval [500000,600000] is greated than its parent
    11/20/2014 15:36:47.062 <2896> <telemetryCore.Query> <1> Incorrect data: Memory category 7 for frame stats query over time interval [600000,700000] is greated than its parent
    11/20/2014 15:36:47.063 <2896> <telemetryCore.Query> <1> Incorrect data: Memory category 7 for frame stats query over time interval [700000,800000] is greated than its parent
    11/20/2014 15:36:47.063 <2896> <telemetryCore.Query> <1> Incorrect data: Memory category 7 for frame stats query over time interval [800000,900000] is greated than its parent
    11/20/2014 15:36:47.064 <2896> <telemetryCore.Query> <1> Incorrect data: Memory category 7 for frame stats query over time interval [900000,1000000] is greated than its parent
    11/20/2014 15:36:47.064 <2896> <telemetryCore.Query> <1> Incorrect data: Memory category 7 for frame stats query over time interval [1000000,1100000] is greated than its parent
    11/20/2014 15:36:47.064 <2896> <telemetryCore.Query> <1> Incorrect data: Memory category 7 for frame stats query over time interval [1100000,1200000] is greated than its parent
    11/20/2014 15:36:47.065 <2896> <telemetryCore.Query> <1> Incorrect data: Memory category 7 for frame stats query over time interval [1200000,1300000] is greated than its parent
    11/20/2014 15:36:47.065 <2896> <telemetryCore.Query> <1> Incorrect data: Memory category 7 for frame stats query over time interval [1300000,1400000] is greated than its parent
    11/20/2014 15:36:47.065 <2896> <telemetryCore.Query> <1> Incorrect data: Memory category 7 for frame stats query over time interval [1400000,1500000] is greated than its parent
    11/20/2014 15:36:47.066 <2896> <telemetryCore.Query> <1> Incorrect data: Memory category 7 for frame stats query over time interval [1500000,1600000] is greated than its parent
    11/20/2014 15:36:47.066 <2896> <telemetryCore.Query> <1> Incorrect data: Memory category 7 for frame stats query over time interval [1600000,1700000] is greated than its parent
    11/20/2014 15:36:47.066 <2896> <telemetryCore.Query> <1> Incorrect data: Memory category 7 for frame stats query over time interval [1700000,1800000] is greated than its parent
    11/20/2014 15:36:47.067 <2896> <telemetryCore.Query> <1> Incorrect data: Memory category 7 for frame stats query over time interval [1800000,1900000] is greated than its parent
    11/20/2014 15:36:47.067 <2896> <telemetryCore.Query> <1> Incorrect data: Memory category 7 for frame stats query over time interval [1900000,2000000] is greated than its parent
    11/20/2014 15:36:47.067 <2896> <telemetryCore.Query> <1> Incorrect data: Memory category 7 for frame stats query over time interval [2000000,2100000] is greated than its parent
    11/20/2014 15:36:47.068 <2896> <telemetryCore.Query> <1> Incorrect data: Memory category 7 for frame stats query over time interval [2100000,2200000] is greated than its parent
    11/20/2014 15:36:47.068 <2896> <telemetryCore.Query> <1> Incorrect data: Memory category 7 for frame stats query over time interval [2200000,2300000] is greated than its parent
    11/20/2014 15:36:47.068 <2896> <telemetryCore.Query> <1> Incorrect data: Memory category 7 for frame stats query over time interval [2300000,2400000] is greated than its parent
    11/20/2014 15:36:47.069 <2896> <telemetryCore.Query> <1> Incorrect data: Memory category 7 for frame stats query over time interval [2400000,2500000] is greated than its parent
    11/20/2014 15:36:47.069 <2896> <telemetryCore.Query> <1> Incorrect data: Memory category 7 for frame stats query over time interval [2500000,2600000] is greated than its parent
    11/20/2014 15:36:47.069 <2896> <telemetryCore.Query> <1> Incorrect data: Memory category 7 for frame stats query over time interval [2600000,2700000] is greated than its parent
    11/20/2014 15:36:47.070 <2896> <telemetryCore.Query> <1> Incorrect data: Memory category 7 for frame stats query over time interval [2700000,2800000] is greated than its parent
    11/20/2014 15:36:47.070 <2896> <telemetryCore.Query> <1> Incorrect data: Memory category 7 for frame stats query over time interval [2800000,2900000] is greated than its parent
    11/20/2014 15:36:47.070 <2896> <telemetryCore.Query> <1> Incorrect data: Memory category 7 for frame stats query over time interval [2900000,3000000] is greated than its parent
    11/20/2014 15:36:47.071 <2896> <telemetryCore.Query> <1> Incorrect data: Memory category 7 for frame stats query over time interval [3000000,3100000] is greated than its parent
    11/20/2014 15:36:47.071 <2896> <telemetryCore.Query> <1> Incorrect data: Memory category 7 for frame stats query over time interval [3100000,3200000] is greated than its parent
    11/20/2014 15:46:30.931 <2896> <telemetryCore.Query> <1> Incorrect data: Memory category 7 for frame stats query over time interval [100000,200000] is greated than its parent
    11/20/2014 15:46:30.933 <2896> <telemetryCore.Query> <1> Incorrect data: Memory category 7 for frame stats query over time interval [200000,300000] is greated than its parent
    11/20/2014 15:46:30.936 <2896> <telemetryCore.Query> <1> Incorrect data: Memory category 7 for frame stats query over time interval [300000,400000] is greated than its parent
    11/20/2014 15:46:30.937 <2896> <telemetryCore.Query> <1> Incorrect data: Memory category 7 for frame stats query over time interval [400000,500000] is greated than its parent
    11/20/2014 15:46:30.937 <2896> <telemetryCore.Query> <1> Incorrect data: Memory category 7 for frame stats query over time interval [500000,600000] is greated than its parent
    11/20/2014 15:46:30.937 <2896> <telemetryCore.Query> <1> Incorrect data: Memory category 7 for frame stats query over time interval [600000,700000] is greated than its parent
    11/20/2014 15:46:30.937 <2896> <telemetryCore.Query> <1> Incorrect data: Memory category 7 for frame stats query over time interval [700000,800000] is greated than its parent
    11/20/2014 15:46:30.938 <2896> <telemetryCore.Query> <1> Incorrect data: Memory category 7 for frame stats query over time interval [800000,900000] is greated than its parent
    11/20/2014 15:46:30.938 <2896> <telemetryCore.Query> <1> Incorrect data: Memory category 7 for frame stats query over time interval [900000,1000000] is greated than its parent
    I run flash code directly on flash_player_11_7_sa.exe. I think the problem may have something to do with ActionScript Sampler of scout, because I can get the correct profiling information  without ActionScript Sampler.
    But I don't know what the information in the log file means.

    We are using Microsoft SQL Server 2008 . but it's well with MySQL & JBoss

  • Highlight text not working in multi-thread client-server application plug-in

    I'm developing a plugin application for my dissertation research on multi-application environment. I have an application server that communicate with the PDF document via plugin.
    The plugin acts as both client and server, depending on the situation.
    - Plugin as Server
             I have a multi-threaded winsock2 IOCP running to catch client connections and when a client connected, get the data from the client (set of words), and highlight these words in the pdf document.
    - Plugin as client
               I use 2 procedures, one to collect all the text from PDF and send to the server using tcp win-socket connection and another to collect data from highlight tool and send these text. both these are not threaded.
    Here's my question, because I want to listen to multiple client connections, when the plugin is the server, I'm running this procedure in a thread and then wait for clients to connect and use IOCP to serve the client connections.  When the client is connected I use the data coming from client to highlight some text in the PDF document. All of these functionalities are already implemented, but when I receive data from client and try to highlight text in the PDF document my application freezes up and stop working. I think this is something to do with the thread. I'm using _beginthreadex to start the server and then another _beginthreadex inside the IOCP worker thread.
    I can post the code, but before that let me know if you can see any problem in this situation. What I see from other posts is that acrobat is not multi-threaded.

    Thanks a lot for the reply.
    I guess I probably need some sort of a notification when the data is received and do a callback to the main thread to run the acrobat API. Is there anyway I can create custom notifications? Something like this,
    AVAppRegisterNotification(AVDocDidOpenNSEL, gExtensionID, ASCallbackCreateNotification( AVDocDidOpen, (void *)DocIsOpenedCallback), NULL);
    or should I use a custom action listener?

  • Force a multi-threaded client to use more than one proxy.

    I have a multi-threaded client app. that I'm using to test our proxy throughput. I've run into the same problem I've seen other people run into where the client application threads all get sent via the same proxy (in my case, I have 16 proxies available and configured in the client config.)
    Now I've seen threads like this one: Re: How to dynamically connect Extend client to proxy server?
    I just wondered, has a solution appeared since that time? I guess Coherence 3.6 and 3.7 have appeared in the interim. I'm on 3.6.1.4.
    My "Coherence specific" code is all localised in each thread and nothing is shared, so I guess the behaviour I'm seeing is something to do with the way Coherence initialises it's client classes within the JVM, rather than something it defers until a cache connection is established.
    Any solutions to this problem, so I can get my multi-threaded client (where each thread opens a NamedCache connection and then establishes a CQC against it) to use all (or at least more) of the available 16 proxies?
    Cheers,
    Steve

    I have a multi-threaded client app. that I'm using to test our proxy throughput. I've run into the same problem I've seen other people run into where the client application threads all get sent via the same proxy (in my case, I have 16 proxies available and configured in the client config.)
    Now I've seen threads like this one: Re: How to dynamically connect Extend client to proxy server?
    I just wondered, has a solution appeared since that time? I guess Coherence 3.6 and 3.7 have appeared in the interim. I'm on 3.6.1.4.
    My "Coherence specific" code is all localised in each thread and nothing is shared, so I guess the behaviour I'm seeing is something to do with the way Coherence initialises it's client classes within the JVM, rather than something it defers until a cache connection is established.
    Any solutions to this problem, so I can get my multi-threaded client (where each thread opens a NamedCache connection and then establishes a CQC against it) to use all (or at least more) of the available 16 proxies?
    Cheers,
    Steve

Maybe you are looking for

  • Error when selecting system during scheduling of background job in RAR

    Hi, I am getting an error when I attempt to schedule a background in RAR. It happens when I go to the multiple system selection option. I select a system and click copy. An error example below appears in the logs even when I dont go ahead and schedul

  • An error occurred while trying to register new iPhone.

    It seems to me that I had this same issue when I tried to register the last iPod I bought. Every time I plug in the new phone, It asks me to register. I use my apple ID log in info and it returns with this error. "An error occurred. The iTunes Store

  • HT4972 Can i use my ipad in ireland

    I live in las vegas. I'm going to Ireland for the summer. Will my ipad work? I bought new last xmas 2011

  • E-Recruitment and/or  Recruitment ???

    Hi all. Could you please tell me the difference between E-Recruitment and Recruitment ?? Those are differents modules in HR that works in collaboration or just can be implemented and work one at the same time? Thanks in advance. Enrique

  • Inserting photo in iMovie, becomes still frame of video before it.

    When I insert a photo into my iMovie it creates a still frame of the video before. Doesn't matter where in the clips I put it and I've tried dragging a photo in from Finder and using the iPhoto in the iMovie application. And, if I put a photo after a