Event-driven Socket Programming

I've developed an application that communicates with a device over TCP/IP. Right now I have an infinite loop in another thread that continually checks for data on the socket, calling Thread.sleep() each time to prevent the receive thread from using the entire CPU, but I think this may be limiting my throughput. I'd like to either find a class that will generate an event for me when data arrives (which I'm doing myself at present), or be able to call wait() and have my thread notify()ed when data arrives on the socket. Can either of these things be done?

I see. Could you post some of your code please? I
suspect you are doing a number of things incorrectly
here. Thread.sleep is not a good sign. I suspect you
may be using available.Yes, I'm using .available(). In the code below, link is a wrapper around a TCP socket. Incoming messages are delineated by a start and end byte, and the parseByte() function switches states and resets the receiveOffset counter depending on each incoming byte. Fully blocking I/O was not an option, as I needed to be able to detect incomplete messages and deliver an event to the application.
                   /* Continue running until the port is closed and there is no data left */
                   while(link != null && (link.isOpen() || receiveOffset > 0)) {
                           /* Read all available bytes and parse them one at a time */
                           while(link.available() > 0) {
                                   byte b;
                                   /* Parse the next input byte */
                                   b = link.read(1)[0];
                                   parseByte(b);
                                   /* Reset the no-input loop counter as there was input */
                                   loopCount = 0;
                           /* Increment the no-input loop counter if there is data in the receive buffer */
                           if(receiveOffset > 0) {
                                   loopCount++;
                           } else {
                                   /* Reset the no-input loop counter as the receive buffer is empty */
                                   loopCount = 0;
                           /* Check for too many loops with data in the receive buffer */
                           if(loopCount > LOOP_MAX) {
                                   /* Incomplete message - code omitted */
                           /* Allow other threads to run */
                           try { Thread.sleep(1); } catch(Exception e) { }
                   }

Similar Messages

  • Supporting Events in Sockets Programming

    1- Is possible to support events in programming Sockets appliaction? I mean that if possible to fire event when data is recieved or there data want to be sent?
    2- I developed an application that read from a permenant socket connection. I enter in a while loop for ever to detect if there any received data or not. This endless loop sloww down the system and take a huge CPU time. Is there any other method for notification without this loop?
    3- How can I know if the socket was diconnected or not?
    Thank you for your help.

    I've posted several simple Socket examples that do exactly those things. If you want to get the results back to Swing as the socket gets data you can send it back with invokeLater. If you want to know when it closes watch for the EOF indication of the receive side. You should also trap the SocketInterrupt on both the send and receive loops. Take a look at the Client and Switch methods on this thread.
    http://forum.java.sun.com/thread.jsp?forum=31&thread=436227&start=21&range=1
    http://forum.java.sun.com/thread.jsp?forum=31&thread=436227&start=28&range=1

  • Periodic reading data with event driven programming

    Hi all
    I want to read data from a device periodically, for example every 2 seconds.
    but I want to use event driven programming in order to response user events.
    now I don't know how to do this......!!
    maybe I should use timed loop or timed sequence structure
    if I use this structures, should I use then inside the while loop or outside the while loop( I mean the while loop that contains the event cases)?
    please help me and accept my thanks....

    You ned to run these in two separate loops. Look at the Producer/Consumer template. Put a two second time-out on the Dequeue Element and you have a loop that will run every two seconds. The loop should also handle information from the event structure.
    Separate loops is the best way of handling this.
    Rob

  • Event-Driven Programming

    Hello Everyone,
    I am new to this forum and also new to event-driven programming. Anyways, I am doing a small exercise to get myself familiar with event-driven programming. In particular, the program responds to keys entered on a keyboard. The exercise in a way resembles how a second hand moves in a clock. So, here's what I am trying to do. Originally the hand points at 12 o'clock. when I press the right arrow key the hand should move 6 degrees to the right and when I press the left arrow key the hand should move 6 degrees to the left. The code I have so far seems fairly correct to me but when I run the program and press the arrow keys on my keyboard nothing happens. Any help would be appreciated and thank you in advance.
    Here is my code:
    import java.awt.*;
    import java.util.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class hittingBalloons extends JFrame{
         hittingBalloons(){
              mouseKeyboardListeners p = new mouseKeyboardListeners();
              add(p);
              p.setFocusable(true);
         public static void main(String[] args){
              hittingBalloons frame = new hittingBalloons();
              frame.setTitle("Hitting Balloons");
              frame.setSize(500,500);
              frame.setLocationRelativeTo(null);
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.setVisible(true);
         public class mouseKeyboardListeners extends JPanel{
              private int xCenter=250;
              private int yCenter=250;
              private int xEnd =250;
              private int yEnd =210;
              private int angle=0;
              private int gunLength=40;
              private int xBall = 150;
              private int yBall = 150;
              private int radius = 20;
              public mouseKeyboardListeners(){
                   addKeyListener(new KeyAdapter(){
                        public void keyPressed(KeyEvent e){
                             if(e.getKeyCode() == KeyEvent.VK_LEFT){
                                  angle = (int)(angle - (Math.PI/30));
                                  xEnd = (int)(xCenter + gunLength*Math.sin(angle));
                                  yEnd = (int)(yCenter - gunLength*Math.cos(angle));
                                  repaint();
                             else if (e.getKeyCode() == KeyEvent.VK_RIGHT){
                                  angle = (int)(angle + (Math.PI/30));
                                  xEnd = (int)(xCenter + gunLength*Math.sin(angle));
                                  yEnd = (int)(yCenter - gunLength*Math.cos(angle));
                                  repaint();
              protected void paintComponent(Graphics g){
                   super.paintComponent(g);
                   g.drawLine(xCenter,yCenter,xEnd,yEnd);
    }

    A few notes and suggestions:
    1) Welcome to the forum!
    2) When posting code, please use code tags as it makes your code easier to read. the FAQ will show you how. e.g.,
    import java.awt.*;
    import java.util.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class hittingBalloons extends JFrame{
         hittingBalloons(){
              mouseKeyboardListeners p = new mouseKeyboardListeners();
              add(p);
              p.setFocusable(true);
         public static void main(String[] args){
              hittingBalloons frame = new hittingBalloons();
              frame.setTitle("Hitting Balloons");
              frame.setSize(500,500);
              frame.setLocationRelativeTo(null);
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.setVisible(true);
         public class mouseKeyboardListeners extends JPanel{
              private int xCenter=250;
              private int yCenter=250;
              private int xEnd =250;
              private int yEnd =210;
              private int angle=0;
              private int gunLength=40;
              private int xBall = 150;
              private int yBall = 150;
              private int radius = 20;
              public  mouseKeyboardListeners(){
                   addKeyListener(new KeyAdapter(){
                        public void keyPressed(KeyEvent e){
                             if(e.getKeyCode() == KeyEvent.VK_LEFT){
                                  angle = (int)(angle - (Math.PI/30));
                                  xEnd = (int)(xCenter + gunLength*Math.sin(angle));
                                  yEnd = (int)(yCenter - gunLength*Math.cos(angle));
                                  repaint();
                             else if (e.getKeyCode() == KeyEvent.VK_RIGHT){
                                  angle = (int)(angle + (Math.PI/30));
                                  xEnd = (int)(xCenter + gunLength*Math.sin(angle));
                                  yEnd = (int)(yCenter - gunLength*Math.cos(angle));
                                  repaint();
              protected void paintComponent(Graphics g){
                   super.paintComponent(g);
                   g.drawLine(xCenter,yCenter,xEnd,yEnd);
    }3) For key listeners to work, the component must have the focus, and JPanels don't get focus by default. You have to call setFocusable(true) first and then request focus in window on the JPanel.
    4) Even better would be to use key binding, and to learn to use these, check out the Sun tutorial.
    Luck and again, welcome!

  • Event Driven Programming is withheld from LabVIEW Base.

    Can anyone give me a good answer why?  Every other programming language in the world has Event Driven Programming (EDP) built in, even free languages.  So when all I wanted was to use LV as a graphical programming language, (hey, that's what the "G" in G-programming stands for) I was disappointed to find that in my undervalued LV Base I can't look for mouse movement, mouse enter, mouse leave, keyboard actions and countless other possibilities that would be standard fare in any other language, unless, I pay over 1200 dollars more for the Full development package.  I know I should have read up on it more before purchasing, and understood what I would be missing out on.  But how was I to know that the fundamental programming function of EDP would be considered on par with Data Acquisition and Signal Processing?  So basically in order to get a complete programming language, I need to spend more than twice the cost of the Base package just to receive the last key component.  And all this because the Evaluation of LV gives you near limitless possibilities, so a new LV programmer gets used to having these tools at his/her disposal, only to yank some of the most critical tools.  So after saying all this, I am pleading for an explanation.  Why isn't there at least some add-on module that would allow a user to install the withheld functionality of EDP to a Base Development package?  Surely making money is the goal of any business, and I won't claim bait and switch here, or any other wrong doing here.  But there is, in my opinion, a marketing misjudgment here.
    -Orion Williams

    Unfortunately to upgrade, it would cost me the difference between the base version and the full version.  What I think is in order is an add-on module that will give customers the functionality of EDP, without having to also pay for signal processing, which is clearly a more robust programming tool, that I don't need.  I am hoping to show NI that by withholding EDP from the base version with no upgrade option except paying for the full version, that their customers who come into LV at the base version are getting an undervalued version, and they know it, and that without at the very least, and add-on module for EDP, isolating smaller business and individuals.  I agree that signal processing, data acquisition and EDP are worth an extra 1300 dollars, but I don't agree that EDP on it's own is worth an extra 1300 dollars, but that's the only option that I have at this moment.  My suggestion is to create an add-on module that includes EDP and sell it for 300 dollars, since I know signal processing is a much more complex feature and is worth more of that upgrade price than EDP.  Of course all versions of LV should include EDP, so if that drives the price of LV base up, so be it.  Just don't let anyone else be fooled into thinking they are buying a Graphical Programming Language unless all the features of a programming language are included at all price points.  Can I get a witness?

  • New LabHSM Toolkit - Agile development of complex event-driven maintainable LabVIEW applications with active objects / actors based on a universal Hierarchical State Machine / statechart template.

    Dear Fellow LabVIEW programmers:
    Most of the systems you deal with are reactive. It means that their
    primary function is constant interaction with their environment by
    sending and receiving events. But most likely, they can have something
    happening inside them too, even when they are not processing messages
    received from outside. So, such systems have to continuosly react to
    external and internal stimuli. Right? Moreover, most likely, they
    consist of subsystems that are reactive too and, in turn, can have
    their own "life", to an extent independent from other parts (with
    which they still communicate, of course). Reactive (event-driven)
    systems are more naturally modeled with active objects. So, why then
    should we try to model and code them with GOOP and its passive
    ("dead"!) objects?
    "Flat" State Machines have been known for decades to have severe
    limitations. It's been more than 20 years since Dr. Harel invented
    Hierarchical State Machines (statecharts) to fight those limitations.
    Then why does NI still tout the same old good Moore FSM as the
    ultimate tool for event-driven programming in LabVIEW in its $995
    State Diagram KIt?
    The LabHSM toolkit we are happy to present, makes it possible to
    easily create and then maintain complex event-driven applications in
    LabVIEW as a collection of HSM-driven active object VIs using a higher
    level of abstraction and agile software development methodologies.
    These active object VIs are created based on a universal Hierarchical
    State Machine ( HSM or statechart ) template. So. all your code looks
    similar regardless of its functionality!
    We all love just jump to code, right? However, to be good boys, we
    need to do design first. Then implement it in code. If the logic is
    modified we need to redo the design first and then redo the code. When
    using LabHSM where behavior information is abstracted into a separate
    HSM data file editable with a supplied editor, there is no need for
    coding separate from design any more. The modified behavior becomes
    code automatically as soon as the HSM file is saved. Design is code!
    The implementation basically follows Dr. Samek's Quantum Programming
    paradigm. (see http://www.quantum-leaps.com). However, as already
    mentioned, LabHSM stores the behavior information in a file separate
    from the code itself. It also adds state dependent priorities to
    events, a separate queue for public events/messages, and, of course,
    some LabVIEW specific code like capturing front panel user events and
    putting them into the private Events queue. Communication and
    instantiation functions are also rather specific for LabVIEW.
    It is available for UNLIMITED PERIOD trial. Please visit
    http://www.labhsm.com for details and download. The site also contains
    references which you may want to check to learn more about
    hierarchical state machines and active object computing.
    Since this is our debut we will appreciate any comments and
    suggestions. Our contact information is available on our site, of
    course.
    Have a G'day!

    Symtx is currently hiring the following position. Please contact me if interested.
    Amy Cable
    Symtx, HR
    [email protected]
    Symtx, the leading supplier of functional test equipment, hires the brightest & most talented engineering professionals to design & manufacture complex custom electronic systems for advanced technology leaders in the defense, aerospace, communications, medical, transportation & semiconductor industries. Symtx’ challenging & dynamic work environment seeks to fill openings with highly qualified electronic engineering design professionals.The ideal candidate will be responsible for defining the requirements, software design and code development, and integration of test control software for custom functional test systems. Candidate should be familiar with data acquisition concepts, instrument control, complex test, measurement and calibration algorithm development and definition and implementation of control interfaces to hardware. Prefer familiarity with instrument control via GPIB, VXI, MXI, RS-232 desirable. Requires BS/MSEE and 3 -7+ yrs of experience in one or several of the following test applications in a Windows NT/2000/XP environment using Labwindows CVI, TestStand, Labview, Visual Basic, C++ and knowledge of RF systems is a plus. Job responsibilities will include software design, development, integration, team leadership, and interfacing with customers( includes PDR’s & CDR’s).

  • Simple Socket Programming, But,.......

    This code is Server, Client Socket program code.
    Client send data to server and then, Server get data and save it
    to file in server.
    I think client works well.
    But, Server.java file have some problem.
    It generate ClassNotFoundException!
    So the result file have garbage value only.
    Any idea please................
    /////////////////////////// Server.java /////////////////////////////////
    import java.io.*;
    import java.net.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Server extends JFrame
         private JTextField enter;
         private JTextArea display;
         ObjectInputStream input;
         ObjectOutputStream output;
         FileOutputStream resultFile;
         public Server(){
              super("Server");
              Container c = getContentPane();
              enter = new JTextField();
              enter.setEnabled(false);
              enter.addActionListener(
                   new ActionListener(){
                        public void actionPerformed(ActionEvent ev){
                             //None
              c.add(enter, BorderLayout.NORTH);
              display = new JTextArea();
              c.add(new JScrollPane(display),
                   BorderLayout.CENTER);
              setSize(300, 150);
              show();
         public void runServer(){
              ServerSocket server;
              Socket connection;
              int counter = 1;
              display.setText("");
              try{
                   server = new ServerSocket(8800, 100);
                   while(true){
                        display.append("Waiting for connection\n" + counter);
                        connection = server.accept();
                        display.append("Connection " + counter +
                             "received from: " + connection.getInetAddress().getHostName());
                        resultFile = new FileOutputStream("hi.txt");
                        output = new ObjectOutputStream(resultFile);
                        output.flush();
                        input = new ObjectInputStream(
                             connection.getInputStream()
                        display.append("\nGod I/O stream, I/O is opened\n");
                        enter.setEnabled(true);
                        DataForm01 data = null;
                        try{
                             data = (DataForm01) input.readObject();
                             output.writeObject(data);
                             data = (DataForm01) input.readObject();
                             output.writeObject(data);
                        catch(NullPointerException e){
                             display.append("Null pointer Exception");
                        catch(ClassNotFoundException cnfex){
                             display.append("\nUnknown Object type received");
                        catch(IOException e){
                             display.append("\nIOException Occured!");
                        if(resultFile != null){
                             resultFile.flush();
                             resultFile.close();
                        display.append("\nUser Terminate connection");
                        enter.setEnabled(false);
                        input.close();
                        output.close();
                        connection.close();
                        ++counter;
              catch(EOFException eof){
                   System.out.println("Client Terminate Connection");
              catch(IOException io){
                   io.printStackTrace();
              display.append("File is created!");
         public static void main(String[] args){
              Server app = new Server();
              app.addWindowListener(
                   new WindowAdapter(){
                        public void windowClosing(WindowEvent e){
                             System.exit(0);
              app.runServer();
    /////////////////////////// client.java /////////////////////////////////
    * Client.java
    * @author Created by Omnicore CodeGuide
    package Client;
    import java.io.*;
    import java.net.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Client extends JFrame
         private JTextField enter;
         private JTextArea display;
         ObjectOutputStream output;
         String message = "";
         //DataForm01 dfrm[];
         public Client(){
              super("Client");
              Container c = getContentPane();
              enter = new JTextField();
              enter.setEnabled(false);
              enter.addActionListener(
                   new ActionListener(){
                        public void actionPerformed(ActionEvent e){
                             //None.
              c.add(enter, BorderLayout.NORTH);
              display = new JTextArea();
              c.add(new JScrollPane(display), BorderLayout.CENTER);
              setSize(300, 150);
              show();
         public void runClient(){
              Socket client;
              try{
                   display.setText("Attemption Connection...\n");
                   client = new Socket(InetAddress.getByName("127.0.0.1"), 8800);
                   display.append("Connected to : = " +
                        client.getInetAddress().getHostName());
                   output = new ObjectOutputStream(
                        client.getOutputStream()
                   output.flush();
                   display.append("\nGot I/O Stream, Stream is opened!\n");
                   enter.setEnabled(true);
                   dfrm = new DataForm01[10];
                   for(int i=0; i<10; i++){
                        dfrm[i] = new DataForm01();
                        dfrm.stn = i;
                        dfrm[i].name = "Jinbom" + Integer.toString(i);
                        dfrm[i].hobby = "Soccer" + Integer.toString(i);
                        dfrm[i].point = (double)i;
                   for(int i=0; i<10; i++){
                        try{
                             output.writeObject(dfrm[i]);
                             display.append(dfrm[i].getData());
                        catch(IOException ev){
                             display.append("\nClass is not founded!\n");
                   DataForm01 dfrm = new DataForm01();
                   dfrm.stn=1;
                   dfrm.name="Jinbom";
                   dfrm.hobby = "Soccer";
                   dfrm.point = (double)0.23;
                   DataForm01 dfrm02 = new DataForm01();
                   dfrm02.stn = 1;
                   dfrm02.name = "Jimbin";
                   dfrm02.hobby = "Soccer";
                   dfrm02.point = 0.4353;
                   try{
                        output.writeObject(dfrm);
                        display.append(dfrm.getData());
                        output.writeObject(dfrm02);
                        display.append(dfrm.getData());
                   catch(IOException ev){
                        display.append("\nClass is not founded!\n");
                   if(output != null) output.flush();
                   display.append("Closing connection.\n");
                   output.close();
                   client.close();
              catch(IOException ioe){
                   ioe.printStackTrace();
         public static void main(String[] args){
              Client app = new Client();
              app.addWindowListener(
                   new WindowAdapter(){
                        public void windowClosing(WindowEvent e){
                             System.exit(0);
              app.runClient();
    /////////////////////////// DataForm01.java /////////////////////////////////
    import java.io.*;
    public class DataForm01 implements Serializable
         int stn;
         String name;
         String hobby;
         double point;
         public String getData(){
              return Integer.toString(stn) + name + hobby + Double.toString(point);

    This is indented code. ^^;
    It's better to view.
    ////////////////////////// Server.java /////////////////////////////////////////
    * Server.java
    * @author Created by Omnicore CodeGuide
    import java.io.*;
    import java.net.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Server extends JFrame
         private JTextField enter;
         private JTextArea display;
         ObjectInputStream input;
         ObjectOutputStream output;
         FileOutputStream resultFile;
         public Server(){
              super("Server");
              Container c = getContentPane();
              enter = new JTextField();
              enter.setEnabled(false);
              enter.addActionListener(
                   new ActionListener(){
                        public void actionPerformed(ActionEvent ev){
                             //None
              c.add(enter, BorderLayout.NORTH);
              display = new JTextArea();
              c.add(new JScrollPane(display),
                     BorderLayout.CENTER);
              setSize(300, 150);
              show();
         public void runServer(){
              ServerSocket server;
              Socket connection;
              int counter = 1;
              display.setText("");
              try{
                   server = new ServerSocket(8800, 100);
                   while(true){
                        display.append("Waiting for connection\n" + counter);
                        connection = server.accept();
                        display.append("Connection " + counter +
                             "received from: " + connection.getInetAddress().getHostName());
                        resultFile = new FileOutputStream("hi.txt");
                        output = new ObjectOutputStream(resultFile);
                        output.flush();
                        input = new ObjectInputStream(
                             connection.getInputStream()
                        display.append("\nGod I/O stream, I/O is opened\n");
                        enter.setEnabled(true);
                        DataForm01 data = null;
                        for(int i=0; i<10; i++){
                             try{
                                  data = (DataForm01) input.readObject();
                                  if(data == null) break;
                                  output.writeObject(data);
                             catch(NullPointerException e){
                                  display.append("Null pointer Exception");
                             catch(ClassNotFoundException cnfex){
                                  display.append("\nUnknown Object type received");
                             catch(IOException e){
                                  display.append("\nIOException Occured!");
                        DataForm01 data = null;
                        try{
                             data = (DataForm01) input.readObject();
                             output.writeObject(data);
                             data = (DataForm01) input.readObject();
                             output.writeObject(data);
                        catch(NullPointerException e){
                             display.append("Null pointer Exception");
                        catch(ClassNotFoundException cnfex){
                             display.append("\nUnknown Object type received");
                        catch(IOException e){
                             display.append("\nIOException Occured!");
                        if(resultFile != null){
                             resultFile.flush();
                             resultFile.close();
                        display.append("\nUser Terminate connection");
                        enter.setEnabled(false);
                        input.close();
                        output.close();
                        connection.close();
                        ++counter;
              catch(EOFException eof){
                   System.out.println("Client Terminate Connection");
              catch(IOException io){
                   io.printStackTrace();
              display.append("File is created!");
         public static void main(String[] args){
              Server app = new Server();
              app.addWindowListener(
                   new WindowAdapter(){
                        public void windowClosing(WindowEvent e){
                             System.exit(0);
              app.runServer();
    ////////////////////////// Client.java /////////////////////////////////////////
    * Client.java
    * @author Created by Omnicore CodeGuide
    package Client;
    import java.io.*;
    import java.net.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Client extends JFrame
         private JTextField enter;
         private JTextArea display;
         ObjectOutputStream output;
         String message = "";
         //DataForm01 dfrm[];
         public Client(){
              super("Client");
              Container c = getContentPane();
              enter = new JTextField();
              enter.setEnabled(false);
              enter.addActionListener(
                   new ActionListener(){
                        public void actionPerformed(ActionEvent e){
                             //None.
              c.add(enter, BorderLayout.NORTH);
              display = new JTextArea();
              c.add(new JScrollPane(display), BorderLayout.CENTER);
              setSize(300, 150);
              show();
         public void runClient(){
              Socket client;
              try{
                   display.setText("Attemption Connection...\n");
                   client = new Socket(InetAddress.getByName("127.0.0.1"), 8800);
                   display.append("Connected to : = " +
                          client.getInetAddress().getHostName());
                   output = new ObjectOutputStream(
                        client.getOutputStream()
                   output.flush();
                   display.append("\nGot I/O Stream, Stream is opened!\n");
                   enter.setEnabled(true);
                   dfrm = new DataForm01[10];
                   for(int i=0; i<10; i++){
                        dfrm[i] = new DataForm01();
                        dfrm.stn = i;
                        dfrm[i].name = "Jinbom" + Integer.toString(i);
                        dfrm[i].hobby = "Soccer" + Integer.toString(i);
                        dfrm[i].point = (double)i;
                   for(int i=0; i<10; i++){
                        try{
                             output.writeObject(dfrm[i]);
                             display.append(dfrm[i].getData());
                        catch(IOException ev){
                             display.append("\nClass is not founded!\n");
                   DataForm01 dfrm = new DataForm01();
                   dfrm.stn=1;
                   dfrm.name="Jinbom";
                   dfrm.hobby = "Soccer";
                   dfrm.point = (double)0.23;
                   DataForm01 dfrm02 = new DataForm01();
                   dfrm02.stn = 1;
                   dfrm02.name = "Jimbin";
                   dfrm02.hobby = "Soccer";
                   dfrm02.point = 0.4353;
                   try{
                        output.writeObject(dfrm);
                        display.append(dfrm.getData());
                        output.writeObject(dfrm02);
                        display.append(dfrm.getData());
                   catch(IOException ev){
                        display.append("\nClass is not founded!\n");
                   if(output != null) output.flush();
                   display.append("Closing connection.\n");
                   output.close();
                   client.close();
              catch(IOException ioe){
                   ioe.printStackTrace();
         public static void main(String[] args){
              Client app = new Client();
              app.addWindowListener(
                   new WindowAdapter(){
                        public void windowClosing(WindowEvent e){
                             System.exit(0);
              app.runClient();
    ////////////////////////// DataForm01.java /////////////////////////////////////////
    * DataForm01.java
    * @author Created by Omnicore CodeGuide
    import java.io.*;
    public class DataForm01 implements Serializable
         int stn;
         String name;
         String hobby;
         double point;
         public String getData(){
              return Integer.toString(stn) + name + hobby + Double.toString(point);

  • Huge Basic Price Drop for LabHSM Toolkit for advanced event-driven development

    Dear fellow LabVIEWers :
    I am happy to announce that to increase the attractiveness of the LabHSM toolkit the basic price was just dropped from about $1,000 to just $249!
    As our website says, the price is not set in stone (even this new low one!). We encourage the prospective clients to make us an offer and we promise that no reasonable offer will be refused. So, some people have already done exactly that – told us a price they could afford and we sold them LabHSM at THEIR price. However, it seems to us that too many people don’t like the (too high in their opinion) basic price but still don’t notice the “Make us an offer” option (despite very large font and bright color) and/or just hesitate to make an offer. We hope that the new, significantly reduced basic price will make the toolkit more attractive to those folks who don’t like to negotiate.
    About LabHSM:
    LabHSM is a professionally designed toolkit that allows creating complex event-driven LabVIEW application as an easily maintainable collection of asynchronously communicating active objects ( actors ) based on a universal Hierarchical State Machine ( HSM or statechart ) template. The LabHSM  toolkit enables the programmer to work on a higher level of abstraction and utilize agile software development methodologies combining design and coding in one highly flexible process.
    Stanislav Rumega, CLA
    H View Labs
    http://labhsm.com

    An update: I am still in Milwaukee, Wisconsin, USA. The current client ran out of projects for me,
    so I am ACTIVELY looking now. An updated resume is attached. If you are in US and any farther from me than Chicago, relocation assistance is highly desired.
    Again,
    I am so fed up with US immigration "process" (almost NINE years here LEGALLY and green card is nowhere in sight!) that would SERIOUSLY consider UK, Australia, Canada, EU if somebody is SERIOUSLY willing
    to help with the papers and relocation.
    An updated resume is attached.
    Recent achievements:
    1. A couple of test stands  for testing  high voltage (15kV, 27kv, 38kV)  high current (up to 100A) reclosers. Those devices are used by electrical utilities companies. They are made by Cooper Power Systems. It's sort of a big three phase breaker but with the brains - it's own computer. Very sophisticated device. It is programmed at which currents and for how long to wait before opening the circuit, when and how many times to try to close it again before locking out, etc. See http://cooperpower.com/Products/Distribution/Reclosers/ for more info on.
    2.Updated the David Boyd's famous Tunnel Wiring Wizard to make it work with LV 8. See LAVA forums: http://forums.lavag.org/index.php?s=&showtopic=211&view=findpost&p=9207
    3. Created a Property and Method Selection (PMS :-)) Assistant to simplify access to undocumented (private) properties and methods in LabVIEW 7 through 8 - very useful for anybody experimenting with VI Scriping features. Again, see it on VI Scripting LAVA forum:
    http://forums.lavag.org/index.php?s=&showtopic=2662&view=findpost&p=10812
    Attachments:
    Stanislav Rumega Resume 05-2006.doc ‏96 KB

  • Wpf: Event driven vs MVVM design pattern

    I'm a beginning coder and I've been working on a WPF app for several months now and struggled to implement anything in MVVM due to time constraits to learn so I coded my program the only way to knew how: with code behind, tight coupling, and a whole bunch of
    spaghetti code.
    My program has grown into 20,000+ lines of messy (but working) code that is mostly event driven. The app I am building will probably be used and continue to be developed for years to come, but I will be the only one working on the code.
    However, now that I have time to start learning MVVM, I'm wondering how useful it really is to follow the MVVM pattern. I'm considering refactoring my code into the MVVM pattern but everything seems 100x difficult to do with little documentation. With using
    code behind and tight coupling, I can make the UI do exactly what I want it to do and everything seems like it can be coded so much faster through the event-driven methods.
    How important is it to follow the MVVM design pattern for WPF apps, especially in the long run? Do you think it's a good idea for me to invest my time to redesigning this app and following an MVVM pattern?

    20k lines is a lot.
    That will mean maintenance will be a significant overhead.
    Anything making maintenance harder will mean maintenance takes longer.
    If you're going to do any serious wpf development ( and 20k lines is serious imo) then you should be using mvvm.
    The thing is though, it's different.
    You will need to learn it before it becomes second nature and doesn't appear to be an overhead.
    It isn't true that "everything" can be coded so much faster with event driven methods.
    In fact a number of things are way easier to do using mvvm rather than code behind.
    If that isn't enough to persuade you.
    Teams use MVVM.
    Go to an interview and tell your prospective team lead you think mvvm is no good and you may as well not go to the interview.
    If it becomes obvious in an interview you haven't learnt mvvm then you will not be chosen.
    Teams also use automated testing.
    This is nigh on impossible with code behind and one of the selling points of mvvm.
    You can test without instantiating a view which means you can run thousands of fast tests in seconds.
    That means you can make changes safe in the knowledge you're not breaking stuff you haven't worked on.
    It means someone else in the team doesn't break your code without realising.
    Since UI and code are decoupled you can makes changes to either or both rather easier - that decoupling = flexibility.
    As your code base grows then re-factoring becomes MASSIVELY faster if you have automated tests in place and your layers are loosely coupled.
    I don't know about this paraticular app you have because I don't know almost anything about it.
    If you plan on doing professional wpf development then I suggest you re-adjust your opinions on MVVM. 
    Please don't forget to upvote posts which you like and mark those which answer your question.
    My latest Technet article - Dynamic XAML

  • Creating Event driven process chain

    Hi all,
    In my scenario there are two chains in which
    1. First chain is normal chain, which we are using to
    load business data.
    2. Second chain will contain start variant and one ABAP
    program that will call first chain and this second
    chain is event driven.
    So can anybody send me relevant documents or
    information regarding how to create event? How to
    schedule process chain using event? and also how to call
    process chain using ABAP program?
    Thanks & Regards
    Ajinkya Deodhar

    Hi,
    Look into the following links:
    http://help.sap.com/saphelp_sem40bw/helpdata/EN/86/6ff03b166c8d66e10000000a11402f/frameset.htm
    http://help.sap.com/saphelp_sem40bw/helpdata/EN/86/6ff03b166c8d66e10000000a11402f/frameset.htm
    Event collector:
    http://help.sap.com/saphelp_sem40bw/helpdata/EN/86/6ff03b166c8d66e10000000a11402f/frameset.htm
    Creation of Event:
    http://help.sap.com/saphelp_sem40bw/helpdata/EN/86/6ff03b166c8d66e10000000a11402f/frameset.htm
    http://help.sap.com/saphelp_sem40bw/helpdata/EN/86/6ff03b166c8d66e10000000a11402f/frameset.htm
    Hope it hepls you

  • Multithread socket programming

    Hello,
    I'm new to socket programming world.
    I've to send/receive the data from a external system thru socket. Since # of data to be processed is huge, I'm thinking to have multiple threads to send/receive thru socket. It looks like socket is NOT thread safe. So I'm thinking to have separate socket connection for each thread. Each thread will create the new socket connection and close it before it dies. Creating a new socket for each thread does not seem to be good practice to me.
    Is this good design for socket programming? If not, please share your ideas.
    I'm also thinking to have socket connecting pooling to re-use the connections. Is there any lib for doing this?
    Thanks for the help

    sorry i was busy on something else till now. thanks for reply.
    Lets say that I've 100 request xml in the blocking queue. I would like to have producer/consumer model. producer will write the request from queue to channel and consumer will capture the response from channel . so sending/receiving happens simultaneously.
    If I have single channel, I''m still not quite sure how i can read/write from channel at the same time. Please clarify with some examples.
    i went thru few article and found following code to read/write. here looks like i have to write all 100 request first into channel and then be ready to read response. is my understanding correct?
    // Check what event is available and deal with it
    if (key.isConnectable()) {
    // finishConnection(key);
    } else if (key.isReadable()) {
    this.read(key);
    } else if (key.isWritable()) {
    this.write(key);
    }

  • Event Driven Kanban Process

    Hi,
    I tried to follow the process mentioned from other threads on this subject but with no success.
    Scenario:
    Header Mtrl: A
    Assembly: B [E-D KANBAN]
    Assembly: C
    There is a requirement for A=100 ea. There must be dep.req generated for B = 100 ea??? as per the event  [correct me if I am wrong].
    How to exectute the above scenario?
    Can anyone guide with the work flow and TCode for the E-D Kanaban.
    Thanks in advance.
    Cheers
    Ramesh

    Q: Well, if the scenario which I mentioned is not ED what exactly it is - Please ellobrate?
    This scenario is not ED, this can be addressed by Kanban with MRP controller, in case of inhouse production it will be with
      the replinshment type 4 .
    Q 1/ If we need to manually create the ED signal in PK23 what advantage does we have compared to the MRP run?
    It is not any advantage, this is how it can be done.
    Q 2/ There is a order for A=100 ea. How the person responsible in the supply area will know that there is a req. for B (ED KANBAN) material?. How the person responsible for the supply area track these requirements?
    In case if you are working with kanban + MRP , you can use the program SAPMMPKC which can be scheduled in the BG to 
    Q 3/ I appreciate, if you could throw more light in - how automatically the ED is triggered once it receive the order/req.?
    Apart from all, i think you need to read more about the kanban and how it works.
    Generally kanban are used where there is continious flow between 2 workcentres.
    ie ) a constant demand and supply .
    10 containes flows between 2 workcentres in which one workcentre is supply and  another one is demand then kanban is used.
    during such situation if you are planing to increase one container just for 1 weeek to meet your increased demand ( like christmas, new year) then Event driven kanban can be used.
    Hope most of your querries are answered . you can also check about kanban here
    http://sap-pphelp.blogspot.com/2010/01/kanban-inhouse-production.html
    Reg
    Dsk

  • ABAP Error:Illegal interruption of the event LOAD-OF-PROGRAM (in MIGO-Goods issue to Production)

    Hi Experts,
    while i am doing MIGO(Goods Issue to Production Order, I am getting the below ABAP Error:
    Please give solution, It is urgent requirement.
    THE ERROR IS:
    Short text
         Illegal interruption of the event LOAD-OF-PROGRAM.
    What happened?
         Error in the ABAP Application Program
         The current ABAP program "/MRSS/SAPLRAP_INT_OB" had to be terminated because it
          has come across a statement that unfortunately cannot be executed.
    Error analysis
         During the flow of the event LOAD-OF-PROGRAM (event for the
         initialization of an ABAP program), a condition occurred under which
         the event was to be left early. This is not permitted as it would
         result in an inconsistent status in the ABAP program.
    Trigger Location of Runtime Error
        Program /MRSS/SAPLRAP_INT_OB
        Include /MRSS/LRAP_INT_OBF00
        Row                                     34
        Module type                             (FORM)
        Module Name                             GLOBAL_INIT
    Source Code Extract
    Line  SourceCde
        4
        5 *&---------------------------------------------------------------------*
        6 *&      Form global_init
        7 *&---------------------------------------------------------------------*
        8 *       text
        9 *----------------------------------------------------------------------*
       10 FORM global_init.
       11
       12 * local data
       13   DATA lv_badi_impl_exists TYPE flag.
       14
       15
       16 * get ref to BAdIs
       17   CALL METHOD cl_exithandler=>get_instance "#EC CI_BADI_GETINST
       18     CHANGING
       19       instance = gv_ref_badi_inter_company.
       20 *  CALL METHOD cl_exithandler=>get_instance
       21 * CHANGING
       22 *      instance = gv_ref_badi_rap_back.
       23 *  CALL METHOD cl_exithandler=>get_instance
       24 *    CHANGING
       25 *      instance = gv_ref_badi_ps_int.
         26   CALL METHOD cl_exithandler=>get_instance "#EC CI_BADI_GETINST

    Hi Rob thanks for your response.  I thought about doing an OSS note however; I would think I would need to get the problem in config corrected first as it contradicts each other.  The problem I am talking about is how they are to return material to vendor....I have never even seen this as a process in my 10 years....
    Process.....when the PO is a return to vendor PO they go to migo and choose the goods receipt and mvmt type 101 and the system will default the 161 in the item level....the two are inconsistent.  If I try to change the top level to a 161 mvmt (as this is what I am used to seeing) it gives the error that the PO is not a stock transport order... Would you agree that I should correct that problem first before creating an OSS note?

  • Events in ABAP Programming

    Hi,
    Can anybody please list out the exact differences between the events 'LOAD-OF-PROGRAM', 'INITIALIZATION' and 'AT SELECTION-SCREEN OUTPUT'.
    Thanks in advance,
    Sujit.

    Hi,
    <u><b>LOAD-OF-PROGRAM:</b></u> When an ABAP program is loaded in an internal session, the runtime environment triggers the LOAD-OF-PROGRAM event, and the corresponding event block is executed.
    The processing block LOAD-OF-PROGRAM has approximately the same function in an ABAP program with type 1, M, F, or S as the constructor method of a class in ABAP Objects.
    Programs wiht type 1, M, F, or S can be loaded into an internal session in two ways:
    Program calls
    Whenever you call a program using SUBMIT or a transaction code, a new internal session is opened. The LOAD-OF-PROGRAM event is therefore called in each program call.
    External procedure calls
    The first time you call an external procedure (subroutine or function module), the main program of the procedure that you called is loaded into the internal session of the calling program. The eventLOAD-OF-PROGRAM is triggered and the corresponding processing block is executed before the procedure that you called. However, subsequent calls from the same calling program to a procedure in the same subroutine pool or function group do not trigger the LOAD-OF-PROGRAM event.
    so it's before the program is loaded in the memory for execution.
    <u><b>INITIALIZATION:</b></u>
    This event occurs before the standard selection screen is called. You can use it, for example, to initialize the input fields of the standard selection screen. This is the only possible way to change the default values of parameters or selection criteria defined in logical databases. To change a selection criterion, you must fill at least the components <seltab>-SIGN, <seltab>-OPTION, and <seltab>-LOW of the selection table <seltab>, otherwise it remains undefined.
    If you want to initialize input fields of the logical database, you need to find out the names of the fields. To do this for the logical database SAPDB<ldb>, use Transaction SLDB or choose Tools
    ABAP Workbench, followed by Development   Programming environ.   Logical databases. You
    can also display the technical information for the required field on the selection screen. To do
    this, call the F1 help for the required field and then choose Technical info. In the field Scrn Field
    of the following dialog box, you then see the name of the field used in the program.
    <u><b>AT SELECTION-SCREEN OUTPUT</b></u>
    event is triggered. This event block allows you to modify the selection screen directly before it is displayed.

  • New version of the LabHSM Toolkit for Complex Event-Driven Development is Now Available!

    A new version of the unique toolkit is now available for download. As announced earlier, LabHSM makes it possible to easily create and then maintain complex event-driven applications in LabVIEW as a collection of HSM-driven active object VIs using a higher level of abstraction and agile software development methodologies. These active object VIs are created based on a universal Hierarchical State Machine ( HSM or statechart ) template. Therefore, all your code looks similar regardless of its functionality!
    So, what’s new in version 1.1?
    • "No hands" block diagram modifications! Version 1.1 actually creates, renames, and removes actions on the block diagram as you define, rename, and remove them in the editor! (No, it can't fill in all the details for you, but it can do some, if you think ahead, by replicating similar actions.)
    • Two new screens, Events Usage and Actions Usage, (available in licensed copies only) clearly show where (in which state(s)/transition(s)) and how (is it an entry action, exit action or event handling action?) a particular event or action is used. Moreover, if after selecting an instance on the list, the Go To button is pressed, it makes the main screen jump to respective location in the HSM structure. In the case of Actions Usage screen, the respective action is also displayed on the block diagram. Thus, these screens provide two more different cross-sections of the HSM data set and two additional ways to navigate it – now along the Actions and Events dimensions too instead of just the state tree in the first version.
    • Version 1.1 can duplicate events or actions, which helps when you've got several that are similar. Changes in the events and actions lists are reflected immediately on the main screen and on the block diagram (which solves the previous problem of deleting a renamed event or action when it's still in use).
    • The Events and Actions List Editors are no longer modal and neither are the Events and Actions Usage screens, so you can have all the panels and the block diagram visible and move freely among them as you build your HSM (a good argument for an even larger monitor).
    • When you save an HSM file, version 1.1 automatically adds the .hsm extension if you leave it out and it remembers the last directory you used.
    • The Loaded VIs utility now can open and close block diagrams (if they are not protected with a password) and display only VIs with modal front panels, if desired—useful for quickly finding and closing accidentally opened (e.g., from the hierarchy window) modal VIs. Make a modal version of this utility and keep it on the Desktop for this purpose.
    • A new example of a simple hierarchical state machine and two more excellent tutorials from Paul F. Sullivan (SULLutions.com) are included into the package. The tutorials are also available online. The overview article has also been extended.
    As before, the LabHSM toolkit is available for UNLIMITED PERIOD trial. Please visit http://www.labhsm.com for details and download. The site also contains references which you may want to check to learn more about hierarchical state machines and active object computing.
    Stanislav Rumega
    NI Certified LabVIEW Developer
    H View Labs
    http://www.labhsm.com
    [email protected]
    US Toll-Free Phone/Fax: 877-570-8684

    I am not really sure if Azure support this but its worth to make your configuration file to support .NET 4.0
    $PShome\PowerShell_ISE.CONFIG and $PSHOME\PowerShell.exe.config will be not existing.
    So you can make an entry in configuration to support .NET framework 4.0
    like shown below
    $config_text = @"
    <?xml version="1.0"?>
    <configuration>
    <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0.30319"/>
    <supportedRuntime version="v2.0.50727"/>
    </startup>
    </configuration>
    $config_text| Out-File $pshome\powershell.exe.config
    $config_text| Out-File $pshome\powershell_ise.exe.config
    Close PowerShell Console and open as administrator.
    Try loading the modules back and let me know.
    Regards Chen V [MCTS SharePoint 2010]

Maybe you are looking for

  • Excise Goods Receipt Without  Only Part I

    Hi, We have done a goods receipt for an excisable material. At the time of goods receipt, we could not select "Only Part I" Now we want to post the Vendor Excise Invoice, I just ran the T Code J1I5 with Classification ROP and I am able to update the

  • ITunes opens with no reason

    Since I got my new iMac, or since I upgraded to iTunes 10 (which happened at the same time), iTunes opens erratically with no iPod or iPhone attached. It even starts playing the first song/book in the list that was opened in the last session. What ca

  • Error related to namespace mismatch in BPEL

    Hi All We are facing an error related to NameSpace of a variable in BPEL process. We are sending a SOAP XML request to a third-party web service and fetching the XML response in a variable. There is a mismatch in the namespace of the variables. The x

  • Bex Query - Specific calculation in query result

    Hi experts! I've received a requirement and I cannot find any way to delivery it using the stantard operation or configuration into Bex Query. We have a query which have three KF with summarization in result. The new requirement is based in the KF "P

  • Idocs are not prosessing even after ALE settings in SAP XI and ECC

    Hi Experts!,                  <b>I have a system which has SAP ECC and SAP XI 3.0 installed with 2 instances  on the same operating system. ( In MMC you can see ECC and XI under the same SAP console tree ). I have made many times all possible ALE set