Simple Socket Program error

I got no no output in either the server/client terminal for the following pair of server/client code. Can anyone please point where have I made a basic mistake in the flow of things...
Server Code:-
import java.io.*;
import java.net.*;
public class TCP_File_Server
     public static void main(String st[])
          try
               String msg="start";
               ServerSocket listen_socket=new ServerSocket(7001);
               while(true)
                    Socket conn_socket=listen_socket.accept();
                    BufferedReader in_client=new BufferedReader(new InputStreamReader(conn_socket.getInputStream()));
                    DataOutputStream out_server=new DataOutputStream(conn_socket.getOutputStream());
                    msg=in_client.readLine();
                    System.out.println(msg);
                    out_server.writeBytes("Wassup ?!");
                    conn_socket.close();                    
          catch(IOException e)
               System.out.println(e.toString());
Client Code:
import java.io.*;
import java.net.*;
public class TCP_File_Client
     public static void main(String st[])
          try
               if(st.length==1)
               String path=st[0];
               Socket clientSocket=new Socket("localhost",7001);
               DataOutputStream out_server=new DataOutputStream(clientSocket.getOutputStream());
               BufferedReader in_server=new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
               out_server.writeBytes(path);     
               System.out.println(in_server.readLine());
               clientSocket.close();
          catch(IOException e)
               System.out.println(e.toString());
}

Have my concepts of Streams thorough bro...! Socket transmission always takes place by byte stream... and even if i use bufferedreader, it has an underlying inputstreamreader which converts byte to char stream, so shouldn't be a problem... :)
Guaranteed to be a problem unless you can guarantee that the bytes you wrote will turn into the characters you expect via the charset used by that implicit InputStreamReader.

Similar Messages

  • First Very Simple Socket Program

    Hello,
    I am learning about Sockets and ServerSockets and how I can use the. I am trying to make the simplest server/client program possible just for my understanding before I go deper into it. I have written two programs. theserver.java and theclient.java the sere code looks like this....
    import java.net.*;
    import java.io.*;
    import java.util.*;
    public class theserver
      public static void main(String[] args)
      {   //  IOReader r = new IOReader();
            int prt = 3333;
            BufferedReader in;
             PrintWriter out;
            ServerSocket serverSocket;
            Socket clientSocket = null;
    try{
    serverSocket = new ServerSocket(prt);  // creates the socket looking on prt (3333)
    System.out.println("The Server is now running...");
    while(true)
        clientSocket = serverSocket.accept(); // accepts the connenction
        clientSocket.getKeepAlive(); // keeps the connection alive
        out = new PrintWriter(clientSocket.getOutputStream(),true);
        in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
         if(in.ready())
         System.out.println(in.readLine()); // print it
    catch (IOException e) {
        System.out.println("Accept failed:"+prt);
    }and the client looks like this
    import java.net.*;
    import java.io.*;
    public class theclient
    public static void main(String[] args)
        BufferedReader in;
        PrintWriter out;
        IOReader r = new IOReader();
        PrintWriter sender;
        Socket sock;
      try{
        sock = new Socket("linuxcomp",3333);  // creates a new connection with the server.
        sock.setKeepAlive(true); // keeps the connection alive
        System.out.println("Socket is connected"); // confirms socket is connected.
        System.out.println("Please enter a String");
         String bob = r.readS();
          out = new PrintWriter(sock.getOutputStream(),true);
        out.print(bob); // write bob to the server
      catch(IOException e)
           System.out.println("The socket is now disconnected..");
    }If you notice in the code I use a class I made called IOReader. All that class is, is a buffered reader for my System.in. (just makes it easier for me)
    Ok now for my question:
    When I run this program I run the server first then the client. I type "hello" into my system.in but on my server side, it prints "null" I can't figure out what I am doing wrong, if I am not converting correctly, or if the message is not ever being sent. I tried putting a while(in.read()) { System.out.println("whatever") } it never reaches a point where in.ready() == true. Kinda of agrivating. Because I am very new to sockets, I wanna aks if there is somthing wrong with my code, or if I am going about this process completely wrong. Thank you to how ever helps me,
    Cobbweb

    An example of Creating a Client Socket (Java socket programming tutorial)
    try {
            InetAddress addr = InetAddress.getByName("hotdir.biz");
            int port = 80;
            // This constructor will block until the connection succeeds
            Socket socket = new Socket(addr, port);
        } catch (UnknownHostException e) {
        } catch (IOException e) {
        // Create a socket with a timeout
        try {
            InetAddress addr = InetAddress.getByName("hotdir.biz");
            int port = 80;
            SocketAddress sockaddr = new InetSocketAddress(addr, port);
            // Create an unbound socket
            Socket sock = new Socket();
            // This method will block no more than timeoutMs.
            // If the timeout occurs, SocketTimeoutException is thrown.
            int timeoutMs = 2000;   // 2 seconds
            sock.connect(sockaddr, timeoutMs);
        } catch (UnknownHostException e) {
        } catch (SocketTimeoutException e) {
        } catch (IOException e) {
        }See socket tutorial here http://www.developerzone.biz/index.php?option=com_content&task=view&id=94&Itemid=36

  • 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);

  • Simple number program error

    I am trying to create a simple program to input to real numbers and display the largest. This will then be used in a menu selection program that I am creating. I keep getting the error:
    ---------- Capture Output ----------
    "C:\j2sdk1.4.2\bin\javac.exe" SmallestNumber.java
    SmallestNumber.java:27: 'else' without 'if'
         else
    ^
    1 error
    Terminated with exit code 1
    But to me - the code looks correct. Can anyone pick up my error?
    I am using the SavitchIn class from the book: "An introduction to computer science" by Walter Savitch
    public class SmallestNumber {
        public static void displayNumber() {
            double num1 = 0;
            double num2 = 0;
            float average, count;
            System.out.println("Plese enter a positive number:");
            num1 = SavitchIn.readDouble();
            System.out.println("Please enter a second postive number:");
            num2 = SavitchIn.readDouble();
            if (num1 > num2);
            System.out.println ("The smallest number is: ");
            System.out.println (num2);
             else
                 if (num2 > num1);
                System.out.println ("The smallest number is: ");
                 System.out.println (num1);
        } //end main
    } //end classI have tried including and removing brackets around both if statemetnts.
    Any help would be appreciated.
    Thankyou

    >
    if (num1 > num2);
    System.out.println ("The smallest number is:
    ber is: ");
    System.out.println (num2);
         else
         if (num2 > num1);
    System.out.println ("The smallest number
    lest number is: ");
         System.out.println (num1);What do you mean "the code looks correct" to you????
    You have a semicolon after the if statement. Also if you have more than one statement to execute for an "if" condition, you need to enclose them in brackets { and }
    Here's the proper code:
             if (num1 > num2) {
               System.out.println ("The smallest number is: ");
               System.out.println (num2);
             } else if (num2 > num1) {
               System.out.println ("The smallest number is: ");
               System.out.println (num1);
             }

  • Simple Socket Question / Error...

    I'm testing out a socket connection for an RDP app on the playbook.
    Flash Builder Burrito 4.5
    Adobe AIR SDK 2.5 Hero
    Playbook SDK 0.9.2
    Playbook Sim 0.9.2
    VMPlayer running in Bridged Networking mode
    public function RDPApp()
                   var socket:Socket = new Socket();
                   socket.addEventListener(Event.CONNECT, onConnect);
                   socket.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
                   socket.addEventListener(Event.CLOSE, onClose);
                   socket.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecurityError);
                   socket.addEventListener(ProgressEvent.SOCKET_DATA, onReceivedData);
                   socket.connect("http://www.google.com", 80);
                   socket.close();
                   stage.nativeWindow.visible = true;
              private function closeWindow(event:MouseEvent):void{
                   stage.nativeWindow.close();
              protected function onConnect(event:Event):void
                   // TODO Auto-generated method stub
              protected function onIOError(event:IOErrorEvent):void
                   trace(event);
              protected function onClose(event:Event):void
                   // TODO Auto-generated method stub
              protected function onSecurityError(event:SecurityErrorEvent):void
                   // TODO Auto-generated method stub
              protected function onReceivedData(event:ProgressEvent):void
                   // TODO Auto-generated method stub
    The code above throws on the sim and on the desktop:
    IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2031: Socket Error. URL:http://www.google.com" errorID=2031]
    Googling this error message indicates that the client flash app has not received the required policy file from the server.
    I was under the impression that AIR apps running on the desktop sandbox (Playbook included) do not require the retrieval of the policy file.
    Any help is much appreciated.
    Matt

    For sockets you need to first load the securitypolicy file then call methods on it.
    ref : http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/Socket.html
    Message was edited by: saisri2k2

  • Run simple java program error

    Hi:
    I followed the step by step at "Your First Cup of Java (for Microsoft Windows)" at
    http://java.sun.com/docs/books/tutorial/getStarted/cupojava/win32.html#
    all the steps work, esecpt for the run program part, I get Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorldApp. but the HelloWorldApp clases is there. and I set my path and classes path at xp enviroment
    classes %CATALINA_HOME%\common\lib\servlet.jar;c:\jdom-b8\build\jdom.jar;c:\jdom-b8\lib\xerces.jar; Library.java;c:\hsqldb\lib\hsqldb.jar
    %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\system32\WBEM;c:\jdk1.4.0_02\bin; %path%
    hope you can help !
    Thank you

    The problem with running the HelloWorldApp is because you have set the classpath.
    It looks like Tomcat and others are installed on your system. Trying to run before you can walk, eh!
    This is your system CLASSPATH and points to directories that contain classes and/or *.jar files that contain classes:
    .;%CATALINA_HOME%\common\lib\servlet.jar;c:\jdom-b8\build\jdom.jar;c:\jdom-b8\lib\xerces.jar;c:\hsqldb\lib\hsqldb.jar
    I don't know why Libary.java is there in your original post because it is a source file and not a class yet; and you don't point directly at a class, only the folder or JAR it is in.
    This is your system PATH and points to directories that contain programs:
    %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\system32\WBEM;c:\jdk1.4.0_02\bin;
    With XP the environment is split into two parts:
    1/ the system environment variables and will prepend to:
    2/ your user environment variables may have the same name and will append to variables in 1/. So there is no need for the %path% bit.
    Make sure that CATALINA_HOME is set to the base folder of the CATALINA(TOMCAT) installation, if you are planning to use it.
    You shouldn't need to set PATH or CLASSPATH for your user ID unless you only want that user id to have access.
    My advice (if it is your machine) is to uninstall Apache/Tomcat and anything else (such as JDOM) that isn't basic Java until you have learned the language. Then delete the CLASSPATH variable and remove the \system32\WBEM; part of the the PATH variable.
    Regards,
    Hugh.

  • Weblogic error while deplying a simple servlet program

    Hi This is a very simple servlet program.
    I am trying to deploy it on the weblogic server but i get this error as follow
    Unable to access the selected application.
    *javax.enterprise.deploy.spi.exceptions.InvalidModuleException: [J2EE Deployment SPI:260105]Failed to create*
    DDBeanRoot for application, 'E:\AqanTech\WebApp1\myApp.war'.
    I have checked everything, right from my code to my web.xml file. I have used a build.bat file to build my war file.
    PLEASE HELP ME TO SOLVE THIS HUGE PROBLEM OF MINE ?
    Thanks,
    Shoeb

    Hi,
    The J2EE Error code siply suggest that there is something wrong in your Deployment Descriptors...
    Can u please post the XML files available inside your "WEB-INF" directory?
    Thanks
    Jay SenSharma
    http://jaysensharma.wordpress.com (WebLogic Wonders Are Here)

  • Error in simple oops program

    Hi experts,
    When executing a simple oops program ..i got the following error. Please correct the code.
    "VAR" is not type-compatible with formal parameter "I_DATA".          
          CLASS main DEFINITION
    CLASS main DEFINITION.
      PUBLIC SECTION.
        "// Instance Methods ( Note we use the statement 'METHODS'
        "// to define an instance method )
        METHODS set_data IMPORTING i_data TYPE string.
        METHODS get_data RETURNING value(r_data) TYPE string.
        METHODS print_attribute IMPORTING i_data TYPE string.
        "// Instance Methods ( Note we use the statement 'CLASS-METHODS'
        "// to define a static method )
        CLASS-METHODS set_classdata IMPORTING i_data TYPE string.
        CLASS-METHODS get_classdata RETURNING value(r_data) TYPE string.
        CLASS-METHODS print_classattribute IMPORTING i_data TYPE string.
      PROTECTED SECTION.
        "// Instance Attribute ( Note we use the statement 'DATA'
        "// to define an instance attribute )
        DATA attribute TYPE string.
        "// Static Attribute ( Note we use the statement 'CLASS-DATA'
        "// to define a static attribute )
        CLASS-DATA classattribute TYPE string.
      PRIVATE SECTION.
        "// Instace event ( Note we use the statement 'EVENTS'
        "// to define aN instance event )
        EVENTS event EXPORTING value(e_data) TYPE string.
        "// Instace event ( Note we use the statement 'CLASS-EVENTS'
        "// to define a static event )
        CLASS-EVENTS classevent EXPORTING value(e_data) TYPE string.
        "// For more informations about events see the following example:
        "// ABAP Objects - Creating your First Local Class - Using Events
    ENDCLASS.                    "main DEFINITION
          CLASS main IMPLEMENTATION
    CLASS main IMPLEMENTATION.
      METHOD set_data.
        CONCATENATE 'Instance Attribute value' i_data
                                   INTO attribute SEPARATED BY space.
      ENDMETHOD.                    "set_data
      METHOD get_data.
        MOVE attribute TO r_data.
      ENDMETHOD.                    "get_data
      METHOD set_classdata.
        CONCATENATE 'Static Attribute value' i_data
                                   INTO classattribute SEPARATED BY space.
      ENDMETHOD.                    "set_classdata
      METHOD get_classdata.
        MOVE main=>classattribute TO r_data.
      ENDMETHOD.                    "get_classdata
      METHOD print_attribute.
        WRITE: i_data, /.
      ENDMETHOD.                    "print_attribute
      METHOD print_classattribute.
        WRITE: i_data, /.
      ENDMETHOD.                    "print_classattribute
    ENDCLASS.                    "main IMPLEMENTATION
    DATA: var type char20.
    START-OF-SELECTION.
      "// Calling a Static method (note we don't have a object )
      "// instead we use the <class name>=><method name>.
      main=>set_classdata( 'SDN' ).
      var = main=>get_classdata( ).
      "// Print the var value
      main=>print_classattribute( var ).
      DATA: object_reference TYPE REF TO main.
      CREATE OBJECT object_reference.
      "// - Calling a Instance Method( Note we have to use a object to
      "// access the insntace components of class main )
      "// - Note we're using the statment "CALL METHOD", see looking for
      "// functional & General methods for more informations
      CALL METHOD object_reference->set_data( 'BPX' ).
      var = object_reference->get_data(  ).
      object_reference->print_attribute( var ).
    Thanks in Advance.
    Regards
    Nani

    Hi Nani,
    try changing your data definition for var from CHAR20 to STRING.
    regards,
    Peter

  • PARSE_APPLICATION_DATA Error during XML = ABAP conversion: Response Message; CX_ST_DESERIALIZATION_ERROR in /1SAI/SAS0446CC11CC6EC1AD4789 Line 24 An error occurred when deserializing in the simple transformation program /1SAI/SAS0446CC11CC6EC1AD4789

    Hi Experts ,
    i have a scenario proxy to soap  where i am getting error while getting the response .
    we are sending the request successfully and getting response .some times we are getting in proxy level error below
    PARSE_APPLICATION_DATA Error during XML => ABAP conversion: Response Message; CX_ST_DESERIALIZATION_ERROR in /1SAI/SAS0446CC11CC6EC1AD4789 Line 24 An error occurred when deserializing in the simple transformation program /1SAI/SAS0446CC11CC6EC1AD4789 (Cha
    Please help us to fix this bug in proxy response.
    Regards
    Ravi

    Hello Ravinder,
    Can you please post the complete stack trace, it seems to be some fields are getting truncated i,e data sent from the program to the proxy object might be violating some length restrictions.
    Please check your message interface field lengths and what is being passed to the proxy.
    Regards,
    Ravi.

  • "Assertion failed" error when executing a simple UCI program

    I am using a simple UCI program (tt1.c) with Xmath version 7.0.1 on Sloaris 2.8 that performs the followings:
    - Start Xmath701
    - Sleep 10 Seconds
    - Load a sysbuild model
    - Stop Xmath
    I am calling the uci executable using the following command:
    > /usr/local/apps/matrixx-7.0.1/bin/xmath -call tt1 &
    In this way everything works fine and the following printouts from the program are produced.
    --------- uci printout ----------
    ## Starting Xmath 701
    ## sleep 10 seconds
    ## load "case_h_cs_ds.xmd";
    ## Stopping Xmath 701
    All the processes (tt1, XMATH, xmath_mon, and sysbld) terminate correctly.
    The problem occurs if the 10 second wait after starting xmath is omitted:
    - Start Xmath701
    - Load a sysbuild model
    - Stop Xmath
    This results to the following printouts:
    --------- uci printout ----------
    ## Starting Xmath 701
    ## load "case_h_cs_ds.xmd";
    Assertion failed: file "/vob1/xm/ipc/ipc.cxx", line 420 errno 0.
    Note that the last line is not produced by the uci program and the tt1 did not
    finish (the printout before stopping xmath "## Stopping Xmath 701" was
    not produced).
    A call to the unix "ps -ef" utility shows that none of the related process has been terminated:
    fs085312 27631 20243 0 10:45:29 pts/27 0:00 tt1
    fs085312 27643 1 0 10:45:30 ? 0:00 /usr/local/apps/matrixx-7.0.1/solaris_mx_70.1/xmath/bin/xmath_mon /usr/local/app
    fs085312 27641 27631 0 10:45:30 ? 0:01 /usr/local/apps/matrixx-7.0.1/solaris_mx_70.1/xmath/bin/XMATH 142606339, 0x8800
    fs085312 25473 25446 0 10:45:33 ? 0:01 sysbld ++ 19 4 7 6 5 8 9 0 25446 ++
    The questions are as follows:
    1- What is "Assertion failed: file "/vob1/xm/ipc/ipc.cxx", line 420 errno 0" and why is that produced?
    2- Should the UCI program waits for end of sysbld initialization before issuing commands?
    3- If the answer to the above question is yes, is there a way to check the termination of sysbld initialization?
    Thanks in advance for you help.
    Attachments:
    tt1.c ‏1 KB

    I tracked down the problem and it is a race condition between the many processes being started up. A smaller delay should also solve the problem. Or, maybe do something else before the first 'load'. The 'load' command tries to launch systembuild and causes the race condition.

  • Simple Webserver SocketException: socket write error

    I'm stuck and need some help solving this problem.
    When I try to get the 404 message with the webserver, I get this in the output console:
    "HttpRequest - java.net.SocketException: Connection reset by peer: socket write error"
    I have found the part that makes the problem, but I can't find a solution.
    I hope someone can help me with this!
                try
                    outputStream.writeBytes(entityBody);
    import java.io.*;
    import java.net.*;
    import java.util.*;
    public final class WebServer
        public static void main(String[] args) throws Exception
            //Port number
            int port = 8080;
            // Establish the listen socket.
            ServerSocket webSocket = new ServerSocket(port);
            // Process HTTP service requests in an infinite loop.
            while(true)
                // Listen for a TCP connection request
                Socket tcpSocket = webSocket.accept();
                HttpRequest httpRequest = new HttpRequest(tcpSocket);
                Thread thread = new Thread(httpRequest);
                thread.start();
    import java.io.*;
    import java.net.*;
    import java.util.*;
    public class HttpRequest implements Runnable
        final static String CRLF = "\r\n";
        private Socket socket;
        private String path = "public_html/";
        public HttpRequest(Socket socket)
            this.socket = socket;
        public void run()
            try
                processReguest();
            catch(Exception ex)
                System.err.println(ex);
        private void processReguest() throws Exception
            // Get a reference to the socket's input and output streams.
            InputStreamReader inputReader = new InputStreamReader(socket.getInputStream());
            DataOutputStream outputStream = new DataOutputStream(socket.getOutputStream());
            BufferedReader buffReader = new BufferedReader(inputReader);
            String requestLine = buffReader.readLine();
            System.out.println();
            System.out.println(requestLine);
            String headerLine = null;
            while((headerLine = buffReader.readLine()).length() != 0)
                System.out.println(headerLine);
            // Extract the filename from the request line
            StringTokenizer tokens = new StringTokenizer(requestLine);
            tokens.nextToken();
            String fileName = tokens.nextToken();
            //Prepend a "." so that the file request is within the current directory
            fileName = path + "." + fileName;
            //Open the request file
            FileInputStream fileInputStream = null;
            boolean fileExists = true;
            try
                fileInputStream = new FileInputStream(fileName);
            catch(FileNotFoundException ex)
                fileExists = false;
            //Construct the response message.
            String statusLine = null;
            String connection = null;
            String contentLength = null;
            String contentTypeLine = null;
            String entityBody = null;
            String contentType = contentType(fileName);
            if(!requestLine.startsWith("GET") && !requestLine.startsWith("HEAD"))
                statusLine = "HTTP/1.0 405 Method Not Allowed" + CRLF;
                contentLength = "Content-Length: 0" + CRLF;
                connection = "Connection: close" + CRLF;
                contentTypeLine = "Content-type: " + "text/html" + CRLF;
                entityBody = "<HTML><HEAD><TITLE>405 - Method Not Allowed</TITLE></HEAD><BODY>405 - Method Not Allowed</BODY></HTML>";
                fileInputStream = null;
                fileExists = false;
            else if(fileExists && !contentType.equals("application/octet-stream"))
                statusLine = "HTTP/1.0 200 OK" + CRLF;
                contentTypeLine = "Content-type: " + contentType(fileName) + CRLF;
                connection = "Connection: close" + CRLF;
                contentLength = "Content-Length: " + Integer.toString(fileInputStream.available()) + CRLF;
            else if(fileExists && contentType.equals("application/octet-stream"))
                statusLine = "HTTP/1.0 415 Unsupported Media Type" + CRLF;
                contentLength = "Content-Length: 0" + CRLF;
                connection = "Connection: close" + CRLF;
                contentTypeLine = "Content-type: " + "text/html" + CRLF;
                entityBody = "<HTML><HEAD><TITLE>415 - Unsupported Media Type</TITLE></HEAD><BODY>415 - Unsupported Media Type</BODY></HTML>";
                fileInputStream = null;
                fileExists = false;
            else
                statusLine = "HTTP/1.0 404 Bad Request" + CRLF;
                contentLength = "Content-Length: 0" + CRLF;
                connection = "Connection: close" + CRLF;
                contentTypeLine = "Content-type: " + "text/html" + CRLF;
                entityBody = "<HTML><HEAD><TITLE>404 - Not Found</TITLE></HEAD><BODY>404 - Not Found</BODY></HTML>";
            // Send the status line
            outputStream.writeBytes(statusLine);
            // Send the connection status
            outputStream.writeBytes(connection);
            // Send the Content-Length
            outputStream.writeBytes(contentLength);
            // Send the content type line
            outputStream.writeBytes(contentTypeLine);
            //Send a blank line to indicate the end of the header lines.
            outputStream.writeBytes(CRLF);
            // Send the enity body
            if(fileExists)
                //Den här funkar??
                sendBytes(fileInputStream, outputStream);
                fileInputStream.close();
            else
                try
                    outputStream.writeBytes(entityBody);
                catch(SocketException ex)
                    System.out.println(ex);
            socket.close();
            inputReader.close();
            outputStream.close();
            buffReader.close();
        private void sendBytes(FileInputStream fileInputStream, DataOutputStream outputStream) throws IOException
            //Construct a 1k buffer to hold bytes on their way to the socket
            byte[] buffer = new byte[1024];
            int bytes = 0;
            // Copy request file inte socket's output stream
            while((bytes = fileInputStream.read(buffer)) != -1)
                outputStream.write(buffer,0, bytes);
        private String contentType(String fileName)
            if(fileName.endsWith(".htm") || fileName.endsWith(".html"))
                return "text/html";
            else if(fileName.endsWith(".jpg") || fileName.endsWith(".jpeg"))
                return "image/jpeg";
            else if(fileName.endsWith(".gif"))
                return "image/gif";
            else if(fileName.endsWith(".png"))
                return "image/png";
            else if(fileName.endsWith(".txt"))
                return "text/plain";
            return "application/octet-stream";
    }

    You've told the client that the content length is zero bytes so I presume it closes the connection as soon as it finishes receiving headers. It depends what client you're using of course but that seems reasonable behaviour...

  • Socket Programming Problem

    I am using multi threading with socket programming. One thread uses socket's output stream to send the data and the other thread keeps waiting for the data to arrive from that socket's input stream.
    Now when the readLine or readObject is excuting on the receiver thread it will be blocked untill data arrives. In which case sending thread will not be able to send the data.
    Now is there any way to make the readLine or readObject method non blocking?
    Please advise ASAP
    thnks

    Below is an example of a simple blocking multi-threaded client program that connects to google. I don't believe I've ever experienced a problem like you're describing before while dealing with Java sockets; perhaps this will give you an idea about what's going wrong. One thread reads from stdin, the other (the main-thread of execution) reads from the socket and writes to the screen.
    java Test
    Then do a GET request to the HTTP server:
    "GET / HTTP/1.0"
    Then press return again and watch it send you google's root page.
    import java.net.*;
    import java.io.*;
    class Test
        Test()
         try
              Socket mySocket = new Socket("www.google.com", 80);
              BufferedReader myReader;
              final BufferedWriter myWriter;
              myWriter = new BufferedWriter(new OutputStreamWriter(mySocket.getOutputStream()));
              Thread myThread = new Thread()
                   public void run()
                       System.out.println("here");
                       try
                       BufferedReader inputReader = new BufferedReader(new InputStreamReader(System.in));
                       String str;
                       while((str = inputReader.readLine()) != null)
                            myWriter.write(str);
                            myWriter.write("\n");
                            myWriter.flush();
                       catch(IOException e)
                        System.err.println("Error reading from stdin.");
                        System.exit(-1);
              myThread.start();
                       System.out.println("there");
              myReader = new BufferedReader(new InputStreamReader(mySocket.getInputStream()));
              String str;
              while((str = myReader.readLine()) != null)
                   System.out.println(str);
         catch(IOException hostExcep)
              System.out.println("Host terminated the connection!");
              hostExcep.printStackTrace();
        public static void main(String args[])
         new Test();
    }

  • Help on Server Socket Programming??????

    hello Friends,
    I need your help on following:
    I am the only person working on this project and the company wants me to prepare a infrastructure of this project and I should also give a demo of this project to my seniors. I will breif you up with my project:
    1. There is this gif image of distillation column. i will be publishing it using JApplet or Applet.
    2. This Image must be seen on internet.
    3. On the circle of these Image the user will click(In all there are five circles, called as controllers)and a dialog box should open thru which user will input the float values(I am using the JOptionPane class to open this dialog box).
    4. The inputed values will the be given to the C program which is the simulator for distillation column.
    5. The C program will generate the output through iterations(Code entirely in C), the output of each program will then be poped up to over the image beside the respective controlled or under the respective controller but definetely over the same gif file.
    6. The number of iteration will depend on how fast the C program converges the inputer parameters. And each output must be show over the gif image and when the final iteration value will appear it should remain on the image until some new value is inputted by the user again by clicking on any of the circle.
    The proposed theory to do this project accoding to me is as follows:
    1. Since each value must be thrown to the user. I beleive this is a real time project. So I decided to use Client Server Networking technology provided by java.
    2. Then I figured out that in this project there should be 2 clients One is the GUI which is the Image screen to receive the input from the user and to show the output to the user. Second client is a java program sitting behind the server which will receive this input data from user and it will have an NATIVE method through which all this input will be given to the C simulator program.
    3. The middle bridge between these two clients will be a server. Which will just pass the data to and fro from both the clients.
    3. The C program will perform iterations using these input values from second client. This C program will then give each iterations output to the Java program using JNI technology. This second client then sends this output value to the GUI clients through server.
    Well another very important thing, I am inexperience in the field of software so I had to do a lot of R&D and this is what I found out. Frankly I am really not sure whether this is the right path to approach to this project or there is some other correct and realistic way than this? Well friends i would certainly request you if you can suggest some other simple or rather correct path or else if this is the right path then would you please suggest me the possible hiches or perticular points where I should concentrate more.
    Well i am eagerly waiting for your reply.

    Since you are publishing your results on the net , it will be a better idea to use JSP?Servlet/Beans architecture instead of swing
    I will propose a architecture as follows:
    Client : Standard Browsers, IE and NS
    Middle Tier: Java Webserver/Application Server
    This will depend on your budget. If u have a fat allowance go for weblogic/websphere . If u are operationg on shoe string budget try for apache , etc
    In the server tier code your application in the follwing architecture
    JSP for presentation: Distillation towers picture, input boxes .. etc
    Servlets for business logic invocation and routing requests: Your JSP submits input values to servlets, which does the processing using Java Bean Components. Since you have a lot of Logic written in C I would suggest to encapsulate these in JavaBean components using JNI technology and reuse the code.
    After processing the servlet again forwards the response to another JSP for output
    Advantages:
    1.Your clients can be thin as most of the processing is done at the server
    2. Thread Management is taken care of by your webserver, which otherwise would be a headache
    3. Writing this through low level socket programming will be much more difficult as you will write your own protocol for communication this will be error prone and not scalable
    If you still decide to go for traditional client server programming using swing, use RMI for communication as I insist that socket programming is very very cumbersome...using your own protocols
    hope this helps
    Shubhrajit

  • [Mac] Could not complete your request because of a program error.

    Hello, I've got the problem with opening the file. It was saved in Photoshop CS 6, everything was ok, but after opening the file in few seconds here the message "Could not complete your request because of a program error." What should I do?? It was making all day long!
    [Title Edited to reflect OS for clarity - Hunt]

    Olga Chu,
    Thank you for that information.
    Yours is not a common error, though I have read of it before. In about 2 decades of using Ps (for most daily), I have never encountered it. However, there are some great folk here, who have seen about everything, and will probably have some solutions - though there might be a few additional questions. You have given them something to work with, so all is not lost yet.
    There is likely something specific to your installation (maybe something as simple as a Permissions issue?), or to your system. Since I am a PC-only person, I will not muck about trying to guess what might translate from my PC's to your Mac. Since the Ps Forums were combined, we have a bunch of Mac experts, who are also experts in Ps. Give them a bit of time, to see your post. I am also going to Edit your title, to reflect the OS, and that should trigger those Mac-users to rush in to help.
    Unless you have a deadline, give them a bit of time, to sort this issue out - I hate to have to redo my Images, if not totally necessary.
    Good luck,
    Hunt

  • Photoshop CS4 "program error"

    I am running MAC OSX 10.5.8 on a g5 and our office recently updated to CS4. For the first week, things went smoothly, now Photoshop is producing an error. "Could not complete your request because of a program error." In order to do anything in PS after I get that error, I have to Force Quit. So far it hasn't effected any other CS4 programs. I have uninstalled photoshop, then reinstalled. It worked for a few days, then started again with the error message. We have 4 machines running CS4 in our office and 2 of the 4 are having the same issue. HELP PLEASE!!! very frustrating.

    I am having the same problem doing something simple as selecting text, here is the text from the PSErrorLog.txt
    I am running OSX 10.4.11
    2009:08:05 10:15:20 : /Volumes/workarea/PS_11_Mac_Daily_Retail/20080919.r.488/photoshop/main/photoshop/xcode/.. /le/sources/ExifSupport.cpp : 3020 : REQUIRE failed
    2009:08:05 10:15:20 : /Volumes/workarea/PS_11_Mac_Daily_Retail/20080919.r.488/photoshop/main/photoshop/xcode/.. /le/sources/ExifSupport.cpp : 3020 : REQUIRE failed
    2009:08:30 00:37:31 : /Volumes/workarea/PS_11_Mac_Daily_Retail/20080919.r.488/photoshop/main/photoshop/xcode/.. /le/sources/ExifSupport.cpp : 3020 : REQUIRE failed
    2009:08:30 00:37:31 : /Volumes/workarea/PS_11_Mac_Daily_Retail/20080919.r.488/photoshop/main/photoshop/xcode/.. /le/sources/ExifSupport.cpp : 3020 : REQUIRE failed
    2009:08:30 00:49:37 : /Volumes/workarea/PS_11_Mac_Daily_Retail/20080919.r.488/photoshop/main/photoshop/xcode/.. /le/sources/ExifSupport.cpp : 3020 : REQUIRE failed
    2009:08:30 00:49:37 : /Volumes/workarea/PS_11_Mac_Daily_Retail/20080919.r.488/photoshop/main/photoshop/xcode/.. /le/sources/ExifSupport.cpp : 3020 : REQUIRE failed
    2009:08:30 01:05:42 : /Volumes/workarea/PS_11_Mac_Daily_Retail/20080919.r.488/photoshop/main/photoshop/xcode/.. /le/sources/ExifSupport.cpp : 3020 : REQUIRE failed
    Haven't installed any plugin just what came with normal installation.
    Anything would help tried deleted preferences.
    Thanks

Maybe you are looking for

  • Blue screen of death when I come from suspend

    I have a T61 laptop and just started having a problem everytime I try to come back from suspend my laptop shows the bluescreen of death if I restart it seems fine till I suspend where it crashes when I come back I would really appreciate help in diag

  • Since updating to ios 8.0.2 I have bluetooth connectivity issues

    I updated my new iPhone 6 to IOS 8.0.2 on Thursday.  I have no problems with BT connectivity to speakers or my Bose headset but it will no longer connect to my Mini Cooper's BT system.  Anybody else having a problem?

  • How to increase the row after matching one opration??

    hello, i am looking  for the logic to go to the next row if data are matched. for example when i run vi it will take first row and in first row  data of the column 3 and 4 are compared with the data which is enterd by user. if data matched then next

  • Problem: TextEdit and RTF

    Since a while TextEdit opens RTF documets as PLAIN TEXT and makes my life harder... what would be the solution? this is what I get to see when I try to open an RTF document created with TextEdit: "{\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf440 {\

  • Problems with inner classes in JasminXT

    I hava problems with inner classes in JasminXT. I wrote: ;This is outer class .source Outer.j .class Outer .super SomeSuperClass .method public createrInnerClass()V      .limit stack 10      .limit locals 10      ;create a Inner object      new Outer