Problem in server program

Hi
My client prog runs in an infinite loop where it captures the screen and creates an image object.
After that it sends the image object to the server prog.
Server program receives it and displays it using Jframe , that is it uses a panel and a button named paste.
So I have used an infinite loop in the server side as well.
Problem is as long as client is running the interface that i used for pasting , pops up but I cant see the paste button
Its only when I close the client side the paste button becomes visible and its also working.
but I need to paste it even when the client side is running.
Any idea where am I going wrong?
The relevant codes are as follows----
SERVER:
public class Test
     public Test() {
     try {
     ServerSocket ser=new ServerSocket(4444);     
     ImageIcon img=new ImageIcon();
     String s1="1";
     for(;;){
        Socket clisoc=ser.accept();     
        DataOutputStream os1 = new DataOutputStream(clisoc.getOutputStream());
        os1.writeUTF(s1);
       ObjectInputStream oin = new ObjectInputStream(clisoc.getInputStream());
        img=(ImageIcon)oin.readObject();
        Image i =img.getImage();
       Test1 e = new Test1(i);
        System.out.println(i);
     os1.close();
     oin.close();
     clisoc.close();
     }catch(Exception e){}
}Test1 class is used for creating the image from the image object.
CLIENT---
public final class Test2 implements ClipboardOwner{
    public static void main (String[]  aArguments ){
     try{
          String s1;
          for(;;){
    Socket clisoc= new Socket("localhost",4444);
    TextTransfer textTransfer = new TextTransfer();
    DataInputStream dis=new DataInputStream(clisoc.getInputStream());
    s1=dis.readUTF();
    if(s1.equals("1")){
    Robot robot=new Robot();
    robot.keyPress(KeyEvent.VK_PRINTSCREEN);
    robot.keyRelease(KeyEvent.VK_PRINTSCREEN);
    BufferedImage g=(textTransfer.getClipboard());
    ImageIcon ic = new ImageIcon(g);
    System.out.println(ic);   
    ObjectOutputStream oos = new ObjectOutputStream(clisoc.getOutputStream());
    Thread.sleep(9000);
    oos.writeObject(ic);
    dis.close();
    oos.close();
    clisoc.close();     
   else
     continue;
    }catch(Exception e){System.out.println(e);}
   }    getClipboard() is the function to catch the clipboard content.
Thanks in advance.

Thanks for replying.
I got rid of the problem by introducing a similar if-else block in the server side as well.
Now I also dont have any Thread.sleep() in either client or server program.
The interface that I used to paste the image pops up alright but the paste button takes almost 3 minutes to appear.
Is it normal in windows 98 (P4)?Mind you , the button is working fine.
would you specify why should I "get rid of other close statements" except oos.close()?
I solved my previous problem by keeping them as it is.

Similar Messages

  • Problem in server program: HELP!!!!

    I just tried to introduce methods in my server program (TCPServer.java). the methods are
    run_server() : for creating server socket object
    [b[accept() [/b]: for Listening to a connection, made to the socket and accepting it.
    getstreams() : initializing the streams
    b]recieve_n_process() : receiving client input and processing it
    send_response(): sending response back to client.
    But now I am getting runtime exception
    C:\Program Files\j2sdk_nb\j2sdk1.4.2\bin\abc>javac TCPServer.java
    C:\Program Files\j2sdk_nb\j2sdk1.4.2\bin\abc>java TCPServer
    Exception in thread "main" java.lang.NullPointerException
    at TCPServer.accept(TCPServer.java:19)
    at TCPServer.main(TCPServer.java:58)
    C:\Program Files\j2sdk_nb\j2sdk1.4.2\bin\abc>
    I know I might have made some silly mistake somewhere, please help me to detect it.
    here is my code TCPServer.java
    import java.io.*;
    import java.net.*;
    class TCPServer {
         private ServerSocket welcomeSocket;
         private Socket connectionSocket;
         private ObjectInputStream Client_input;
         private ObjectOutputStream  Client_output;
         private     String clientSentence;
         private String capitalizedSentence;
         private void run_server() throws Exception
          ServerSocket welcomeSocket = new ServerSocket(80);
         private void accept() throws Exception
         {connectionSocket = welcomeSocket.accept(); }
         private void getstreams() throws IOException
         Client_output = new ObjectOutputStream(connectionSocket.getOutputStream());
         Client_output.flush();
             Client_input =  new ObjectInputStream(connectionSocket.getInputStream());
         private void recieve_n_process() throws Exception
         clientSentence = (String ) Client_input.readObject();
         capitalizedSentence = clientSentence.toUpperCase() + '\n';
         private void send_response() throws IOException
         Client_output.writeObject(capitalizedSentence);
      public static void main(String argv[]) throws Exception
         TCPServer server = new TCPServer();
         try{
         server.run_server();
          while(true) {
              server.accept();
                server.getstreams() ;
              server.recieve_n_process();
              server.send_response();
         } catch(EOFException eofException) {}
           catch (IOException ioException) {}     
        }It was working fine before I introduced these methods. Earlier it was like this
    import java.io.*;
    import java.net.*;
    class TCPServer {
      public static void main(String argv[]) throws Exception
          String clientSentence;
          String capitalizedSentence;
          ServerSocket welcomeSocket = new ServerSocket(80);
          while(true) {
                       Socket connectionSocket = welcomeSocket.accept();
               ObjectInputStream inFromClient =  new ObjectInputStream(connectionSocket.getInputStream());
               ObjectOutputStream  outToClient =
                 new ObjectOutputStream(connectionSocket.getOutputStream());
               clientSentence = (String ) inFromClient.readObject();
               capitalizedSentence = clientSentence.toUpperCase() + '\n';
               outToClient.writeObject(capitalizedSentence);

    hello every one,
    i got it where is the problem. I had declared the object of ServerSocket class locally in run_server(). It had to be declared globally though.
    private void run_server() throws Exception
         ServerSocket welcomeSocket = new ServerSocket(80);
    this one works out
    private void run_server() throws Exception
         welcomeSocket = new ServerSocket(80);
         }

  • HTTP Client/Server program problems

    Hi all,
    I am doing an exercise in which I create a Client and Server program. I send a GET request but nothing seems to happen. There is obviously something I'm missing. Could it be a badly formed request? The code is below. Any help is appreciated.
    Client program.....
    import java.io.*;
    import java.net.*;
    import java.util.StringTokenizer;
    public class HTTPClient{
        String host, path;
        int port;
        public static void main (String argv[]){
         new HTTPClient(argv[0]);
        public HTTPClient(String url){
         try{
             URL myURL = new URL(url);
             host = myURL.getHost();
             port = myURL.getPort();
             System.out.println("Port = " + port);
             if (port == -1) port = 30280;;
             path = myURL.getPath();
             if (path.equals("")) path =  "/";
             Socket s = new Socket(InetAddress.getByName(host), port);
             sendRequest(s.getOutputStream());
             printResponse(s.getInputStream());
             s.close();
         catch(MalformedURLException murl){
             System.out.println("Badly formatted URL " + murl.getMessage());
         catch(IOException e){
             System.out.println("Problem initialising socket " + e.getMessage());
        public void sendRequest(OutputStream out){
              StringBuffer buf = new StringBuffer();
              buf.append("GET /AC095.html HTTP/1.1\r\n");
              buf.append("Host: http://students.odl.qmul.ac.uk\r\n\r\n");
              try{
                   out.write(buf.toString().getBytes("US-ASCII"));
              catch (IOException e) {System.out.println(e.getMessage());
        public void printResponse(InputStream in){
             try{
                  while (in.available() <= 0)
                  Thread.sleep(500);
                  while (in.available() > 0)
                  System.out.print((char) in.read());
                  System.out.println ("");
             catch (IOException e) {
                  System.out.println(e.getMessage());
             catch (InterruptedException ie) {
                  System.out.println("Error waiting for response " + ie.getMessage());
         /* Read in the response from the HTTP server and print it out */
    }Server code......
    import java.io.*;
    import java.net.*;
    import java.util.*;
    public class HTTPServer{
        String version = null;
         public String httpVer;
        public static void main(String argv[]){
         new HTTPServer(Integer.parseInt(argv[0]));
        public HTTPServer(int port){
         boolean listening = true;
         try{
              ServerSocket ss = new ServerSocket(port);
              System.out.println("HTTP Server running and listening for requests...");
              while (listening){
               Socket mySocket = ss.accept();
               InputStream in   = mySocket.getInputStream();
               readHeaders(in);
               String response = getResponse();
               OutputStream out = mySocket.getOutputStream();     
               out.write(response.getBytes("US-ASCII"));
               out.flush();
               mySocket.close();
          catch(Exception e){System.out.println(e.getMessage());}
        private String getResponse(){
             StringBuffer responseBuf = new StringBuffer();
             responseBuf.append (httpVer + " 200 OK\r\n");
             responseBuf.append ("Content-type: text/html\r\n");
             responseBuf.append ("Content-length: 119\r\n");
             responseBuf.append ("<HTML>\r\n");
             responseBuf.append ("<TITLE> My served web document </TITLE>\r\n");
             responseBuf.append ("</HEAD>\r\n");
             responseBuf.append ("<BODY>\r\n");
             responseBuf.append ("<H1> Hello from the server! </H1>\r\n");
             responseBuf.append ("</BODY>\r\n");
             responseBuf.append ("</HTML>\r\n\r\n");
             String responseStr = responseBuf.toString();
             responseStr = responseStr.trim();
         return "";
        private void readHeaders(InputStream in) throws IOException {
         StringBuffer sbuf = new StringBuffer();
         int ch;
         String clientStr;
         //This loop reads in all of the input until there is nothing left to read.
         //All of the characters are appended to the string buffer.
         while ((ch = in.read()) != -1) {
              sbuf.append((char) ch);
         //clientStr will hold string in string buffer without any leading or
         //trailing white space.
         clientStr = sbuf.toString();
         clientStr = clientStr.trim();
         //Split clientStr into substrings and store them in an array.
         String [] tokens = clientStr.split(" ");
         //Obtains HTTP version
         httpVer = tokens [2];
    }Cheers,
    Chris

    I've written out.flush() in the server program. When I attempt to connect to the server it just hangs. I've modified the code locally to request a webpage from elsewhere and it works so it can't be the format of my GET request. I assume that the problem has to be in the Server program. Is it not reading in and understanding the /r/n properly?

  • Problem with socket programming(Vista)

    I'm not sure if this has something to do with windows vista.
    I wrote simple echo client and server programs and the client program contains these lines
    String hostname="172.16.54.22"; //My comp's IP
    int portNo=6666;
    mySocket=new Socket(hostname, portNo);
    Now the problem is that the client program is able to communicate with the server only when I run both of them in xp machines or if I run the server in vista and client in xp. The client is not able to connect to the server when both the client and server are running in a vista machine or if the server is running in xp and client in vista.
    It'd be nice if any of you could throw some light on this issue.
    PS:
    It doesn't work even if I turn the firewall off
    The programs work well when I give hostname="localhost" or hostname="127.0.0.1"
    Here are my programs
    //EchoClient.java
    import java.io.*;
    import java.net.*;
    import java.util.*;
    class EchoClient
         public static void main(String args[])
              String hostname="172.16.54.25"; //My ip address
              int portNo=6666;
              //if(args[1]
              //PrintWriter out=null;
              Socket mySocket=null;
              BufferedReader networkIn=null;
              BufferedReader userIn=null;
              PrintWriter sockOut=null;
              try
                   mySocket=new Socket(hostname, portNo);
                   networkIn=new BufferedReader(new InputStreamReader(mySocket.getInputStream()));
                   userIn=new BufferedReader(new InputStreamReader(System.in));
                   sockOut= new PrintWriter(mySocket.getOutputStream());
                   System.out.println("Connected to Echo Server\n");
                   System.out.println("Enter a series of lines (\"end\" to exit)\n");
                   while(true)
                        String myLine=userIn.readLine();
                   //     System.out.println(myLine);
                        if(myLine.equals("end"))
                             break;
                        sockOut.println(myLine);
                        sockOut.flush();
                        System.out.println(networkIn.readLine());
              catch(IOException exc)
                   System.err.println(exc);
              finally
                   try{
                   if(networkIn!=null) networkIn.close();
                   if(sockOut!=null) sockOut.close();}
                   catch(IOException exc){ }
                   EchoServer.java
    //EchoServer.java
    import java.io.*;
    import java.net.*;
    class EchoServer
         public static void main(String args[])
              int portNo=6666;
              ServerSocket serverSock=null;
              try
                   serverSock=new ServerSocket(portNo);
                   System.out.println("Echo Server Started\n\n");
                   while(true)
                        Socket clientSock=serverSock.accept();
                        new Thread(new EchoServerThread(clientSock)).start();
              catch(IOException exc)
                   System.err.println(exc);
         EchoServerThread.java
    //EchoServerThread.java
    import java.io.*;
    import java.net.*;
    import java.util.*;
    public class EchoServerThread implements Runnable
         public Socket clientSock;
         EchoServerThread(Socket sock)
              clientSock=sock;
         public void run()
              System.out.println("\nAccepted Connection from a Client");
              try{
              BufferedReader in=new BufferedReader(new InputStreamReader(clientSock.getInputStream()));
              BufferedReader userIn=new BufferedReader(new InputStreamReader(System.in));
              PrintWriter out= new PrintWriter(clientSock.getOutputStream());
                        /*In sockIn=new In(clientSock);
              Out sockOut=new Out(clientSock);*/
              String str;
              while((str=in.readLine())!=null)
                   out.println(str);
                   out.flush();
              System.out.println("Closing Connection from a Client");
              out.close();
              in.close();
              catch(IOException exc)
                   System.err.println(exc);
         

    Sorry everyone but I'd been giving a wong IP address thinking it's my own. The problem's solved.
    Thanks for the response Peter.

  • "iTunes has stopped working.  A problem caused the program to stop working correctly.   Windows will close the program and notify you if a solution is available."

    Whenever I connect to the iTunes store i receive an error message "iTunes has stopped working.  A problem caused the program to stop working correctly.   Windows will close the program and notify you if a solution is available."    This causes iTunes to close.  I am using iTunes version 10.5.0.142 on a Windows Vista (64) PC.  I have reinstalled iTunes selecting the "repair" option and also uninstalled and reinstalled iTunes.  Any help will be deeply appreciated.  Thank you.  Below is the result of the diagnositc.
    Microsoft Windows 7 x64 Home Premium Edition Service Pack 1 (Build 7601)
    HP-Pavilion BN474AV-ABA HPE-150t
    iTunes 10.5.0.142
    QuickTime not available
    FairPlay 1.13.35
    Apple Application Support 2.1.5
    iPod Updater Library 10.0d2
    CD Driver 2.2.0.1
    CD Driver DLL 2.1.1.1
    Apple Mobile Device 4.0.0.96
    Apple Mobile Device Driver 1.57.0.0
    Bonjour 3.0.0.10 (333.10)
    Gracenote SDK 1.9.3.494
    Gracenote MusicID 1.9.3.106
    Gracenote Submit 1.9.3.136
    Gracenote DSP 1.9.3.44
    iTunes Serial Number 002FAD94098CD0E0
    Current user is not an administrator.
    The current local date and time is 2011-11-13 22:08:54.
    iTunes is not running in safe mode.
    WebKit accelerated compositing is enabled.
    HDCP is not supported.
    Core Media is supported.
    Video Display Information
    NVIDIA, NVIDIA GeForce GT 220
    **** External Plug-ins Information ****
    No external plug-ins installed.
    Genius ID: 2cb3fff3fa771d265b0f8ffdcca13b55
    **** Network Connectivity Tests ****
    Network Adapter Information
    Adapter Name: {F4A2029C-16AA-4BDF-8DB7-9EC2A75B5991}
    Description: Realtek PCIe GBE Family Controller
    IP Address: 192.168.1.6
    Subnet Mask: 255.255.255.0
    Default Gateway: 192.168.1.1
    DHCP Enabled: Yes
    DHCP Server: 192.168.1.1
    Lease Obtained: Sun Nov 13 21:09:29 2011
    Lease Expires: Mon Nov 14 21:09:29 2011
    DNS Servers: 192.168.1.1
    Active Connection: LAN Connection
    Connected: Yes
    Online: Yes
    Using Modem: No
    Using LAN: Yes
    Using Proxy: No
    SSL 3.0 Support: Enabled
    TLS 1.0 Support: Disabled
    Firewall Information
    Windows Firewall is on.
    iTunes is NOT enabled in Windows Firewall.
    Connection attempt to Apple web site was successful.
    Connection attempt to browsing iTunes Store was successful.
    Connection attempt to purchasing from iTunes Store was successful.
    Connection attempt to iPhone activation server was successful.
    Connection attempt to firmware update server was successful.
    Connection attempt to Gracenote server was successful.
    Last successful iTunes Store access was 2011-11-13 22:02:08.
    **** CD/DVD Drive Tests ****
    LowerFilters: PxHlpa64 (2.0.0.0),
    UpperFilters: GEARAspiWDM (2.2.0.1),
    E: hp DVD A DH16ABLH, Rev 3HD9
    Data or MP3 CD in drive.
    Found 1 songs on CD, playing time 15:40 on CDROM media.
    Track 1, start time 00:02:00
    Get drive speed succeeded.
    The drive CDR speeds are: 8 16 24 32.
    The drive CDRW speeds are: 8.
    The drive DVDR speeds are: 8.
    The drive DVDRW speeds are: 8.
    The last failed audio CD burn had error code 4251(0x0000109b). It happened on drive E: hp CDDVDW TS-H653R on CDR media at speed 24X.
    **** Device Connectivity Tests ****
    iPodService 10.5.0.142 (x64) is currently running.
    iTunesHelper 10.5.0.142 is currently running.
    Apple Mobile Device service 3.3.0.0 is currently running.
    Universal Serial Bus Controllers:
    Intel(R) 5 Series/3400 Series Chipset Family USB Enhanced Host Controller - 3B34. Device is working properly.
    Intel(R) 5 Series/3400 Series Chipset Family USB Enhanced Host Controller - 3B3C. Device is working properly.
    FireWire (IEEE 1394) Host Controllers:
    VIA 1394 OHCI Compliant Host Controller. Device is working properly.
    Connected Device Information:
    Bruce's iTouch, iPod touch (2nd generation) running firmware version 4.2.1
    Serial Number: 1C9053CC201
    **** Device Sync Tests ****
    Sync tests completed successfully.

    Same exact thing with me.  And no help from apple.  Just dropped nearly $600 and cannot get a decent working setup.
    Apple's only suggestion was to uninstall iTunes and Quicktime, and re-install... of course (the I.T. Crowd tactic).
    The crash happens only on iTunes store access.

  • Problem in Server side includes using Tomcat

    Problem in Server side includes using Tomcat:
    I am trying out small programs in servlet.
    I get one example program for server side includes from net.
    The code is:
    <HTML>
    <HEAD><TITLE>Times!</TITLE></HEAD>
    <BODY>
    <P>
    The current time in London is!!! :
    <SERVLET CODE="CurrentTime" codebase="../servlet">
    <PARAM NAME="zone" VALUE="GMT">
    </SERVLET>
    </P>
    </BODY>
    </HTML>
    I placed this test.shtml file in tomcat-home/webapps/ROOT folder and i kept the servlet in WEB-INF/classes folder.
    I renamed the servlets-ssi.jar and i removed the comments for SSI in web.xml file.
    When i run the servlet separately, i am getting the correct result. But if i run shtml file with the URL : http://localhost:8080/Test.shtml,
    i am getting the result as:
    The current time in London is!!! :
    It is not invoking servlet program.
    CAN ANYONE HELP ON THIS!
    Thanks.

    Thanks...as u said I tried putting dir & found that
    my file was saved as Ch1Servlet.java.txt instead for
    Ch1Servlet.java......So that was a problem.Now I'm
    able to compile.Oh, yeah. Notepad will do that to you. I think when you save in Notepad if you put quotes around the name "Whatever.java" then it won't add the .txt.
    But on compiling I'm getting the following error
    package java.servlet.* does not exist
    package java.servlet.http.* does not exist
    package java.io.* does not exist
    Do u the reason for this??? The servlet stuff is java[b]x.servlet. For the io stuff, I don't know, I'd have to see your code. Either you have a typo or a corrupt installation.

  • JCo server programming, properties and connection settings

    Greetings, SAP professionals.
    The reason I come to this forum is that I'm hoping to gain some insights into the use of the SAP Java Connector (JCo). I am a developer who was tasked with making a new component for a systems integration application. As is typical of integration software, our app can link together various different systems using a variety of protocols, as well as providing the means to apply business logic on messages passed from one location to another. We already have a connector acting as an SAP client which was implemented using JCo. Now, we were asked to develop a new component: a server capable of accepting RFCs from a remote SAP system acting as client. The server is to be created using the JCo classes, so basically an extension of JCo.Server, with some logic for creating function templates from configuration files.
    However, while I'm understanding the structure of the Java API, it's not entirely clear to me just what the classes do. I've found the JavaDoc for JCo to be mostly descriptive of the interface of classes and methods, but not really explaining what these achieve, or how. So I'm hoping to be set straight, as I fear I'm kind of misunderstanding the functionality of JCo... Being mainly an integrations developer, I unfortunately often have to settle for gaining a superficial knowledge of a variety of systems to quickly interface with them, so I don't have any prior knowledge of SAP but still need to be able to implement something with JCo without too much delay.
    The most important question I have is this: when a JCO.Server implementation is started, does it act as a fully standalone component capable of receiving calls, or does it merely act as a sort of listener for some main SAP system? I'm not talking about a reliability on the two .dll files (or .so for Linux) that are required for the use of JCo, I just wish to know if the JCo package is entirely self-sufficient for server functionality or if it is intended to be linked to some SAP system.
    A second problem I have is that the parameters passed to various constructors aren't clear to me... I'm not familiar with SAP terminology, nor have I worked with any client apps that make use of an SAP system.
    The meaning of client strings, gwhost, gwservice, ashost, system IDs and program IDs mostly elude me, especially when it comes to knowing what client parameters must match what server parameters.
    In order to familiarize myself with the classes, I've tried playing around with them a bit trying to create a small test app that first starts a JCO.Server instance, then tries to make a remote function call to it with a JCO.Client (within the same class, for simplicity and debugging purposes). I was wondering if this actually makes sense... Would a JCo client be capable of connecting to a JCo server, all running purely in Java, or is that nonsense?
    To eliminate some common troubleshooting options, I'll quicly describe the steps I've taken:
    Both librfc32.dll and sapjcorfc.dll were placed in the Windows system32 folder. Maybe only librfd32 needs to be placed there, but I copied both anyway to make sure.
    The directory containing the jar file and both dll files is included in my environment path variable.
    I've added a line to the C:\Windows\system32\drivers\etc\services file as follows:
    sapgw00          3300/tcp                           #SAP System Gateway Port
    I've opened port 3300 in my Windows firewall. In fact, I also tested with the firewall completely turned off.
    However, I do not manage to get my test class to work. I've tried ports 3300, 3200 and 3600. I've tried various permutations of the client and server properties. I've tried removing the line from the services file, which would prompt the client to state upon connecting that the service "sapgw00" is unknown. When I add it back in, the error changes to "partner not reached", so it is definitely picking something up.
    The server itself starts just fine, but connecting through a client doesn't work. My class source code is posted below. Maybe what I'm trying to do doesn't make any sense, but at the moment it's my best guess.
    I realize this is a pretty long post and the class, while not exactly big, also implies a bit of reading of its own. But if anyone could give me any answers that are new to me, I'd be hugely grateful. Right now I'm kind of stuck, and just setting up the service and letting our customer test on it is a somewhat slow approach that can't match developing and testing on one and the same host.
    Preliminary thanks to everyone who took the effort to read this.
    //Start of code
    import java.util.Properties;
    import com.sap.mw.jco.IFunctionTemplate;
    import com.sap.mw.jco.IMetaData;
    import com.sap.mw.jco.IRepository;
    import com.sap.mw.jco.JCO;
    public class Test {
         public static void main(String[] args) {
              Test test = new Test();
              ServerThread serverThread = test.new ServerThread();
              serverThread.start();
              while(!serverThread.isReady) {
                   try {
                        Thread.sleep(5000);
                   } catch(final InterruptedException i) {
                        System.out.println("Rudely awakened");
              try {
    //               JCO.Function func = getSampleFunction(test, "STAY");
    //               serverThread.server.handleRequest(func);
    //               System.out.println(func.getExportParameterList().toXML());
    //               func = getSampleFunction(test, "STOP");
    //               serverThread.server.handleRequest(func);
    //               System.out.println(func.getExportParameterList().toXML());
                   final Properties clientProps = getClientProps();
                   JCO.Client client = JCO.createClient(clientProps);
                   client.connect();
                   IRepository rep = JCO.createRepository("1", client);
                   IFunctionTemplate templ = rep.getFunctionTemplate("TEST_FUNC");
                   JCO.Function function = templ.getFunction();
                   function.getImportParameterList().setValue("STAY", "FIELD1");
                   client.execute(function);
                   JCO.Function function2 = templ.getFunction();
                   function2.getImportParameterList().setValue("STOP", "FIELD1");
                   client.execute(function2);
              } catch(final Exception e) {
                   e.printStackTrace(System.out);
                   serverThread.requestStop();
                   while(serverThread.isAlive) {
                        try {
                             Thread.sleep(5000);
                        } catch(final InterruptedException i) {
                             System.out.println("Rudely awakened");
              } finally {
         private static Properties getClientProps() {
              final Properties props = new Properties();
              props.setProperty("jco.client.client", "100");
              props.setProperty("jco.client.user", "");
              props.setProperty("jco.client.passwd", "");
              props.setProperty("jco.client.lang", "");
              props.setProperty("jco.client.sysnr", "00");
              props.setProperty("jco.client.ashost", "/H/localhost/S/sapgw00");
              props.setProperty("jco.client.gwhost", "localhost");
              props.setProperty("jco.client.gwserv", "sapgw00");
              return props;
         public class ServerThread extends Thread {
              public void run() {
                   isAlive = true;
                   IRepository repos = new TestRepository("testrep");
                   repos.addFunctionInterfaceToCache(getFunctionInterface());
                   server = new TestServer(repos);
                   server.start();
                   System.out.println("Server successfully started");
                   isReady = true;
                   while(!stop) {
                        try {
                             Thread.sleep(1000);
                        } catch(final InterruptedException i) {
                             System.out.println("Wouldn't let me sleep...");
                        stop = server.stopRequested;
                   server.stop();
                   isAlive = false;
                   System.out.println("Server successfully stopped");
              public void requestStop() {
                   server.requestStop();
              public TestServer server;
              public boolean isReady = false;
              public boolean isAlive = false;
         public class TestServer extends JCO.Server {
              public TestServer(IRepository rep) {
                   super("localhost", "sapgw00", "PROGID", rep);
              public void handleRequest(JCO.Function fct) {
                   try {
                        JCO.ParameterList importParams = fct.getImportParameterList();
                        final String importXML = importParams.toXML();
                        System.out.println("XML representation of import parameters: ");
                        System.out.println(importXML);
                        final String input = importParams.getString("FIELD1");
                        System.out.println("FIELD1 value: " + input);
                        JCO.ParameterList exportParams = fct.getExportParameterList();
                        if(input.equals("STOP")) {
                             exportParams.getField("FIELD2").setValue("OK");
                             stopRequested = true;
                   catch(JCO.AbapException ex) {
                        throw ex;
                   catch(Throwable t) {
                        throw new JCO.AbapException("SYSTEM_FAILURE", t.getMessage());
              public boolean checkAuthorization(String functionName, int authorMode, String partner, byte[] key) {
                   System.out.println(functionName + " " + partner);
                   return true;
              public void requestStop() {
                   stopRequested = true;
              public boolean stopRequested = false;
         public class TestRepository extends JCO.BasicRepository implements IRepository {
              public TestRepository(String name) {
                   super(name);
         public static IMetaData getFunctionInterface() {
              JCO.MetaData metaData = new JCO.MetaData("TEST_FUNC");
              metaData.addInfo("FIELD1", IMetaData.TYPE_STRING, 4);
              metaData.setFlags(0, IMetaData.IMPORT_PARAMETER);
              metaData.addInfo("FIELDX", IMetaData.TYPE_STRING, 8);
              metaData.setFlags(1, IMetaData.IMPORT_PARAMETER & IMetaData.OPTIONAL_PARAMETER);
              metaData.addInfo("FIELD2", IMetaData.TYPE_STRING, 2);
              metaData.setFlags(2, IMetaData.EXPORT_PARAMETER);
              return metaData;
         public static JCO.Function getSampleFunction(Test test, String s) {
              TestRepository testRep = test.new TestRepository("testrepository");
              testRep.addFunctionInterfaceToCache(getFunctionInterface());
              JCO.Function func = testRep.getFunctionTemplate("TEST_FUNC").getFunction();
              func.getImportParameterList().setValue(s, "FIELD1");
              return func;
         private static boolean stop = false;

    If I understood you correctly, you want to provide a "service" that can be called from SAP. To provide this service you've chosen to implement an (external) RFC server program via JCo. One common method for RFC server programs is to register in SAP on the gateway - you do this by supplying the three parameters
    <ol>
    <li><b>jco.server.gwhost</b> -  SAP gateway host on which the server should be registered (so this would be the server name or IP address of the SAP gateway; localhost is only correct, if your RFC server program runs on the same server as the SAP gateway)</li>
    <li><b>jco.server.gwserv</b>  - Gateway service, i.e. the port on which a registration can be done</li>
    <li><b>jco.server.progid</b> - Program ID under which your RFC server program can be reached (free, made-up case sensitive name, that should represent the service your RFC server is providing)</li>
    </ol>
    So essentially you're creating a listener, that is registered in SAP and waits for any invocations. Within SAP they will define a <i>RFC destination</i>, which basically represents a TCP/IP connection pointing to the SAP gateway where you registered with the given program ID. If you want more details, check the SAP help pages for <a target="_blank" href="http://help.sap.com/saphelp_nw04/helpdata/en/22/04262b488911d189490000e829fbbd/content.htm">RFC destinations</a> (you're looking for destination type <b>T</b>, see explanations <a target="_blank" href="http://help.sap.com/saphelp_nw04/helpdata/en/22/042652488911d189490000e829fbbd/content.htm">here</a>).
    Usually gateway host and service (port) are given to you by the SAP basis folks and you tell them which program ID you're using. They will then enter those parameters in an RFC destination of type <b>T</b> in SAP. So no need for any of the client parameters you've mentioned. Although, I'd like to repeat, it's usually handy to also have SAP logon parameters maintained on your RFC server program, so that you can utilize the repository data from SAP (might be irrelevant in your case).
    Hope this clarifies it a bit...

  • How to modify a code of a RFC Server Program

    Hello,
    In order to connect a BI System to a new ECC System, I need to modify a RFC Server Program.
    Please can you tell how can I modify this program?
    Thanks

    I think you are trying to run both server and client
    on one machine!!!
    It is impossible, your server is blocking the port to
    send packets, so you must run client on another
    computer!!!It's not impossible to run a client and server on the same machine just for testing or as a demo. Just have the server listen on one port and the client use a different port.
    No need to use 2 seperate computers. I've done it one computer before without a problem.
    Nick

  • Having problem starting server

    I am running into this problem starting server in weblogic 9.1, The server changes to RUNNING mode but throws this error after this .
    Here is stdout:
    C:\projects\config\ddev91>echo $Header: /u01/projects/cvs/omega/build/conf/weblogic/startwl.cmd,v 1.11 2005/11/16 15:55:51 rphillips Exp $
    $Header: /u01/projects/cvs/omega/build/conf/weblogic/startwl.cmd,v 1.11 2005/11/16 15:55:51 rphillips Exp $
    A subdirectory or file filestore already exists.
    Remote Debugging is Off
    Using Default memory model
    C:\projects\config\ddev91>if not exist c:\projects\config\ddev91\servers\ddev-desktop\data\ldap\ldapfiles\nul.ext (
    echo LDAP files no found, calling authwl_desktop.cmd
    call authwl_desktop.cmd
    C:\projects\config\ddev91>"/bea91/jdk150_04\bin\java" -Xms256m -Xmx512m -XX:MaxPermSize=128m -Dweblogic.alternateTypesDirectory=c:/projects/config/ddev91/lib/mbeantypes -DProductionModeEnabled=true -Dorg.xml.sax.driver="weblogic.apache.xerces.parser
    s.SAXParser" -DEJBNoClassLoader -Dcom.frontier.epn.EPNI_Handler_lookup="com.emergis.els.server.persistence.loan.handler.EPNIHandler" -Dlog4j.configuration=file:/projects/config/ddev91/props/log4j.properties -Dcom.frontier.epn.log4j=/projects/config/d
    dev91/props/log4j.properties -Dconfig.path=/projects/config/ddev91/props -Dweblogic.Domain=ddev91 -Dcallback.listener.config=/projects/config/ddev91/props/EPNI.properties -Dweblogic.Name=ddev-desktop "-Dbea.home=/bea91" "-Djava.security.policy==/bea9
    1/weblogic91/lib/weblogic.policy" "-Dweblogic.management.username=system" "-Dweblogic.management.password=weblogic" "-Dcom.frontier.epn.USE_PSTMT=true" -Dweblogic.RootDirectory=c:\/projects\/config\/ddev91 weblogic.Server
    <Jan 25, 2006 9:56:36 AM EST> <Notice> <WebLogicServer> <BEA-000395> <Following extensions directory contents added to the end of the classpath:
    C:\projects\config\ddev91\lib\client.jar;C:\projects\config\ddev91\lib\cmn-log.jar;C:\projects\config\ddev91\lib\commons-beanutils-1.6.1.jar;C:\projects\config\ddev91\lib\commons-collections-2.1.jar;C:\projects\config\ddev91\lib\commons-httpclient-2.
    0.jar;C:\projects\config\ddev91\lib\cos.jar;C:\projects\config\ddev91\lib\CR096950_61sp4.jar;C:\projects\config\ddev91\lib\CR177114_81sp3.jar;C:\projects\config\ddev91\lib\DbLog-bin-jdk14.jar;C:\projects\config\ddev91\lib\DbLog-bin-jdk15-generics.jar
    ;C:\projects\config\ddev91\lib\DbLog-bin-jdk15.jar;C:\projects\config\ddev91\lib\elsStartup.jar;C:\projects\config\ddev91\lib\FrontierEPN-jdk14.jar;C:\projects\config\ddev91\lib\FrontierEPN.jar;C:\projects\config\ddev91\lib\gnu-regexp-1.1.4.jar;C:\pr
    ojects\config\ddev91\lib\iText.jar;C:\projects\config\ddev91\lib\jakarta-regexp-1.3.jar;C:\projects\config\ddev91\lib\jaxb-rt-1.0-ea.jar;C:\projects\config\ddev91\lib\jaxb-xjc-1.0-ea.jar;C:\projects\config\ddev91\lib\jcert.jar;C:\projects\config\ddev
    91\lib\jpedal-jdk13.jar;C:\projects\config\ddev91\lib\jpedal-jdk14.jar;C:\projects\config\ddev91\lib\jsse.jar;C:\projects\config\ddev91\lib\jstl.jar;C:\projects\config\ddev91\lib\log4j.jar;C:\projects\config\ddev91\lib\mbeantypes\eLendingProviders.ja
    r;C:\projects\config\ddev91\lib\ojdbc14-10.2.0.1.0.jar;C:\projects\config\ddev91\lib\ojdbc14-9.2.0.5.jar;C:\projects\config\ddev91\lib\omegaUtils.jar;C:\projects\config\ddev91\lib\resolver.jar;C:\projects\config\ddev91\lib\standard.jar;C:\projects\co
    nfig\ddev91\lib\struts-1.2.4.jar;C:\projects\config\ddev91\lib\testsupport\classes12.jar;C:\projects\config\ddev91\lib\testsupport\commons-beanutils-1.6.1.jar;C:\projects\config\ddev91\lib\testsupport\commons-collections-2.1.jar;C:\projects\config\dd
    ev91\lib\testsupport\commons-digester-1.5.jar;C:\projects\config\ddev91\lib\testsupport\commons-httpclient-2.0.jar;C:\projects\config\ddev91\lib\testsupport\commons-logging-1.0.3.jar;C:\projects\config\ddev91\lib\testsupport\freemarker-2.3rc3.jar;C:\
    projects\config\ddev91\lib\testsupport\handlerTraceTool.jar;C:\projects\config\ddev91\lib\testsupport\httpunit-1.6.1.jar;C:\projects\config\ddev91\lib\testsupport\js.jar;C:\projects\config\ddev91\lib\testsupport\junit.jar;C:\projects\config\ddev91\li
    b\testsupport\junit3.8.1.jar;C:\projects\config\ddev91\lib\testsupport\junitperf.jar;C:\projects\config\ddev91\lib\testsupport\nekohtml-0.9.1.jar;C:\projects\config\ddev91\lib\testsupport\optionalEls.jar;C:\projects\config\ddev91\lib\testsupport\quar
    tz-1.4.0.jar;C:\projects\config\ddev91\lib\testsupport\soapclient\axis.jar;C:\projects\config\ddev91\lib\testsupport\soapclient\commons-discovery.jar;C:\projects\config\ddev91\lib\testsupport\soapclient\commons-logging.jar;C:\projects\config\ddev91\l
    ib\testsupport\soapclient\jaxrpc.jar;C:\projects\config\ddev91\lib\testsupport\soapclient\saaj.jar;C:\projects\config\ddev91\lib\testsupport\soapclient\wsdl4j.jar;C:\projects\config\ddev91\lib\testsupport\xercesImpl.jar;C:\projects\config\ddev91\lib\
    testsupport\xmlParserAPIs.jar;C:\projects\config\ddev91\lib\testsupport\xmlunit1.0.jar;C:\projects\config\ddev91\lib\testsUtils.jar;C:\projects\config\ddev91\lib\tiles.jar;C:\projects\config\ddev91\lib\tncore.jar>
    <Jan 25, 2006 9:56:36 AM EST> <Info> <WebLogicServer> <BEA-000377> <Starting WebLogic Server with Java HotSpot(TM) Client VM Version 1.5.0_04-b05 from Sun Microsystems Inc.>
    <Jan 25, 2006 9:56:37 AM EST> <Info> <Management> <BEA-141107> <Version: WebLogic Server 9.1 Mon Dec 12 19:26:33 EST 2005 689178 >
    <Jan 25, 2006 9:56:40 AM EST> <Info> <WebLogicServer> <BEA-000215> <Loaded License : \bea91\license.bea>
    <Jan 25, 2006 9:56:40 AM EST> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to STARTING>
    <Jan 25, 2006 9:56:40 AM EST> <Info> <WorkManager> <BEA-002900> <Initializing self-tuning thread pool>
    <Jan 25, 2006 9:56:41 AM EST> <Notice> <Log Management> <BEA-170019> <The server log file C:\projects\config\ddev91\servers\ddev-desktop\logs\ddev-desktop.log is opened. All server side log events will be written to this file.>
    <Jan 25, 2006 9:56:41 AM EST> <Error> <Socket> <BEA-000438> <Unable to load performance pack. Using Java I/O instead. Please ensure that wlntio.dll is in: 'C:\bea91\jdk150_04\bin;.;C:\WINDOWS\system32;C:\WINDOWS;/bea91/weblogic91\bin;c:\OptimizeitSui
    te\OptimizeitSuite42;C:\jikes-1.22\bin;C:\bea91\jdk150_04\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Common Files\Roxio Shared\DLLShared;C:\Program Files\cvsnt;C:\apache-ant-1.6.5\bin;%JAVA_HOME\bin;C:\jikes-1.18\bin
    ;"C:\Program Files\GNU\WinCvs 2.0";C:\Oracle\product\10.1.0\Client_1\bin;C:\Oracle\product\10.1.0\Client_1\jre\1.4.2\bin\client;C:\Oracle\product\10.1.0\Client_1\jre\1.4.2\bin;;/oracle/ora90\bin'
    >
    <Jan 25, 2006 9:56:42 AM EST> <Notice> <Security> <BEA-090082> <Security initializing using security realm myrealm.>
    <Jan 25, 2006 9:56:46 AM EST> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to STANDBY>
    <Jan 25, 2006 9:56:46 AM EST> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to STARTING>
    <Jan 25, 2006 9:56:48 AM EST> <Notice> <Log Management> <BEA-170027> <The server initialized the domain log broadcaster successfully. Log messages will now be broadcasted to the domain log.>
    <Jan 25, 2006 9:56:48 AM EST> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to ADMIN>
    <Jan 25, 2006 9:56:48 AM EST> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to RESUMING>
    <Jan 25, 2006 9:56:49 AM EST> <Notice> <Server> <BEA-002613> <Channel "Default[1]" is now listening on 127.0.0.1:7001 for protocols iiop, t3, ldap, http.>
    <Jan 25, 2006 9:56:49 AM EST> <Notice> <Server> <BEA-002613> <Channel "Default" is now listening on 10.44.0.171:7001 for protocols iiop, t3, ldap, http.>
    <Jan 25, 2006 9:56:49 AM EST> <Notice> <WebLogicServer> <BEA-000331> <Started WebLogic Admin Server "ddev-desktop" for domain "ddev91" running in Development Mode>
    <Jan 25, 2006 9:56:49 AM EST> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to RUNNING>
    <Jan 25, 2006 9:56:49 AM EST> <Notice> <WebLogicServer> <BEA-000360> <Server started in RUNNING mode>
    <Jan 25, 2006 9:56:50 AM EST> <Error> <HTTP> <BEA-101359> <The servlet weblogic.servlet.AsyncInitServlet init method failed while it was run in the background. The exception was: java.lang.NoClassDefFoundError: org/apache/commons/digester/RuleSet.
    java.lang.NoClassDefFoundError: org/apache/commons/digester/RuleSet
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:242)
    at weblogic.servlet.AsyncInitServlet.createDelegate(AsyncInitServlet.java:43)
    at weblogic.servlet.AsyncInitServlet.initDelegate(AsyncInitServlet.java:92)
    at weblogic.servlet.internal.WebAppServletContext$AsyncInitRequest.run(WebAppServletContext.java:1641)
    Truncated. see log file for complete stacktrace
    >

    The only thing abnormal is
    java.lang.NoClassDefFoundError: org/apache/commons/digester/RuleSet
    Do you have the digester's jar in the WEB-INF/lib of you application?

  • Multi-threaded server programming

    Hello, I meet a problem and don't know how to solve it: I have created a multi-threaded server program which receives multiple users from their own PCs. The server program receives users'commands and echo it back to all users who are currently connecting to my server. I store every clientSocket connecting to my server into a vector. My question is: how the server broadcasts a user command to other users? And how the server knows to which user he will echo the command to since the hostName and port number are the same to every user currently connecting to my server? Thanks a lot.

    You should look at extending the Socket class to encorporate user details. Either use what peter suggested or make the user pass a username (or something) when they connect.
    When you want to broadcast to all users just enumerate through your vector and send each one the command. If you mean the user performs a task on their application and you want to produce the same results in all the other users apps then its down to you to code it. When user1 clicks on a button the app must send a command (eg. a string) to the server which sends the same string to all other users. When the user receives this string it performs some task.
    Is that what you mean?
    Ted.

  • File transfer, read write through sockets in client server programming java

    Hello All, need help again.
    I am trying to create a Client server program, where, the Client first sends a file to Server, on accepting the file, the server generates another file(probably xml), send it to the client as a response, the client read the response xml, parse it and display some data. now I am successful sending the file to the server, but could not figure out how the server can create and send a xml file and send it to the client as response, please help. below are my codes for client and server
    Client side
    import java.io.BufferedInputStream;
    import java.io.BufferedOutputStream;
    import java.io.BufferedReader;
    import java.io.DataInputStream;
    import java.io.DataOutputStream;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileWriter;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.io.PrintWriter;
    import java.net.InetAddress;
    import java.net.Socket;
    import java.net.UnknownHostException;
    public class XMLSocketC
         public static void main(String[] args) throws IOException
              //Establish a connection to socket
              Socket toServer = null;
              String host = "127.0.0.1";     
              int port = 4444;
              try
                   toServer = new Socket(host, port);
                   } catch (UnknownHostException e) {
                System.err.println("Don't know about host: localhost.");
                System.exit(1);
            } catch (IOException e) {
                System.err.println("Couldn't get I/O for the connection to host.");
                System.exit(1);
              //Send file over Socket
            //===========================================================
            BufferedInputStream fileIn = null;
              BufferedOutputStream out = null;
              // File to be send over the socket.
              File file = new File("c:/xampp/htdocs/thesis/sensorList.php");
              // Checking for the file to be sent.
              if (!file.exists())
                   System.out.println("File doesn't exist");
                   System.exit(0);
              try
                   // InputStream to read the file
                   fileIn = new BufferedInputStream(new FileInputStream(file));
              }catch(IOException eee)
                   System.out.println("Problem, kunne ikke lage fil");
              try
                   InetAddress adressen = InetAddress.getByName(host);
                   try
                        System.out.println("Establishing Socket Connection");
                        // Opening Socket
                        Socket s = new Socket(adressen, port);
                        System.out.println("Socket is clear and available.....");
                        // OutputStream to socket
                        out = new BufferedOutputStream(s.getOutputStream());
                        byte[] buffer = new byte[1024];
                        int numRead;
                        //Checking if bytes available to read to the buffer.
                        while( (numRead = fileIn.read(buffer)) >= 0)
                             // Writes bytes to Output Stream from 0 to total number of bytes
                             out.write(buffer, 0, numRead);
                        // Flush - send file
                        out.flush();
                        // close OutputStream
                        out.close();
                        // close InputStrean
                        fileIn.close();
                   }catch (IOException e)
              }catch(UnknownHostException e)
                   System.err.println(e);
            //===========================================================
            //Retrieve data from Socket.
              //BufferedReader in = new BufferedReader(new InputStreamReader(toServer.getInputStream()));
              DataInputStream in = new DataInputStream(new BufferedInputStream(toServer.getInputStream()));
              //String fromServer;
            //Read from the server and prints.
              //Receive text from server
              FileWriter fr = null;
              String frn = "xxx_response.xml";
              try {
                   fr = new FileWriter(frn);
              } catch (IOException e1) {
                   // TODO Auto-generated catch block
                   e1.printStackTrace();
              try{
                   String line = in.readUTF();                    //.readLine();
                   System.out.println("Text received :" + line);
                   fr.write(line);
              } catch (IOException e){
                   System.out.println("Read failed");
                   System.exit(1);
            in.close();
            toServer.close();
    public class XMLSocketS
          public static void main(String[] args) throws IOException
              //Establish a connection to socket
               ServerSocket serverSocket = null;
                 try {
                     serverSocket = new ServerSocket(4444);
                 } catch (IOException e) {
                     System.err.println("Could not listen on port: 4444.");
                     System.exit(1);
              Socket clientLink = null;
              while (true)
                        try
                             clientLink = serverSocket.accept();
                           System.out.println("Server accepts");
                             BufferedInputStream inn = new BufferedInputStream(clientLink.getInputStream());
                             BufferedOutputStream ut = new BufferedOutputStream(new FileOutputStream(new File("c:/xampp/htdocs/received_from_client.txt")));
                             byte[] buff = new byte[1024];
                             int readMe;
                             while( (readMe = inn.read(buff)) >= 0)
                             {     //reads from input stream, writes the file to disk
                                  ut.write(buff, 0, readMe);
                             // close the link to client
                             clientLink.close();                         
                             // close InputStream
                             inn.close();                         
                             // flush
                             ut.flush();                         
                             // close OutputStream
                             ut.close();     
                             //Sending response to client     
                             //============================================================
                             //============================================================
                             System.out.println("File received");
              }catch(IOException ex)
              {System.out.println("Exception.");}
                        finally
                             try
                                  if (clientLink != null) clientLink.close();
                             }catch(IOException e) {}
                 clientLink.close();
                 //serverSocket.close();
    }

    SERVER
    import java.net.*;
    import java.io.*;
    public class XMLSocketS
          public static void main(String[] args) throws IOException
                   //Establish a connection to socket
               ServerSocket serverSocket = null;
                 try {
                     serverSocket = new ServerSocket(4545);
                 } catch (IOException e) {
                     System.err.println("Could not listen on port: 4444.");
                     System.exit(1);
              Socket clientLink = null;
                  try
                             clientLink = serverSocket.accept();
                         System.out.println("Server accepts the client request.....");
                         BufferedInputStream inn = new BufferedInputStream(clientLink.getInputStream());
                             BufferedOutputStream ut = new BufferedOutputStream(new FileOutputStream(new File("c:/xampp/htdocs/received_from_client.txt")));
                             byte[] buff = new byte[1024];
                             int readMe;
                             while( (readMe = inn.read(buff)) >= 0)
                             {     //reads from input stream, writes the file to disk
                                  ut.write(buff, 0, readMe);
                             ut.flush();                         
                             //Sending response to client     
                             //============================================================
                             BufferedInputStream ftoC = null;
                             BufferedOutputStream outtoC = null;
                             // File to be send over the socket.
                             File file = new File("c:/xampp/htdocs/thesis/user_registration_response.xml");
                             try
                                  // InputStream to read the file
                                   ftoC = new BufferedInputStream(new FileInputStream(file));
                             }catch(IOException eee)
                             {System.out.println("Problem reading file");}
                             // OutputStream to socket
                             outtoC = new BufferedOutputStream(clientLink.getOutputStream());
                             byte[] buffer = new byte[1024];
                             int noRead;
                             //Checking if bytes available to read to the buffer.
                             while( (noRead = ftoC.read(buffer)) >= 0)
                                  // Writes bytes to Output Stream from 0 to total number of bytes
                                  outtoC.write(buffer, 0, noRead);
                             outtoC.flush();
                             //============================================================
                             System.out.println("File received");
              }catch(IOException ex)
              {System.out.println("Exception.");}
                        finally
                             try
                                  if (clientLink != null) clientLink.close();
                             }catch(IOException e) {}
                 clientLink.close();
                 //serverSocket.close();
          }CLIENT SIDE
    import java.io.*;
    import java.net.*;
    public class XMLSocketC
              @SuppressWarnings("deprecation")
              public static void main(String[] args)
                   // Server: "localhost" here. And port to connect is 4545.
                   String host = "127.0.0.1";          
                   int port = 4545;
                   BufferedInputStream fileIn = null;
                   BufferedOutputStream out = null;
                   // File to be send over the socket.
                   File file = new File("c:/xampp/htdocs/thesis/sensorList.xml");
                   try
                        // InputStream to read the file
                        fileIn = new BufferedInputStream(new FileInputStream(file));
                   }catch(IOException eee)
                   {System.out.println("Problem");}
                   try
                             System.out.println("Establishing Socket Connection");
                             // Opening Socket
                             Socket clientSocket = new Socket(host, port);
                             System.out.println("Socket is clear and available.....");
                             // OutputStream to socket
                             out = new BufferedOutputStream(clientSocket.getOutputStream());
                             byte[] buffer = new byte[1024];
                             int numRead;
                             //Checking if bytes available to read to the buffer.
                             while( (numRead = fileIn.read(buffer)) >= 0)
                                  // Writes bytes to Output Stream from 0 to total number of bytes
                                  out.write(buffer, 0, numRead);
                             // Flush - send file
                             out.flush();
                             //=======================================
                             DataInputStream in = new DataInputStream(new BufferedInputStream(clientSocket.getInputStream()));
                             BufferedWriter outf = new BufferedWriter(new FileWriter("c:/xampp/htdocs/received_from_server.txt",true));
                             String str;
                             while(!(str = in.readLine()).equals("EOF")) {     
                                  System.out.println("client : Read line -> <" + str + ">");
                                  outf.write(str);//Write out a string to the file
                                  outf.newLine();//write a new line to the file (for better format)
                                  outf.flush();
                             //=======================================
                             // close OutputStream
                             out.close();
                             // close InputStrean
                             fileIn.close();
                             // close Socket
                             clientSocket.close();
                        }catch (IOException e)
                        {System.out.println("Exception.");}
         Could you please point where am I doing the stupid mistake, client to server is working properly, but the opposite direction is not.
    Thanks

  • Issue in Registered Server Program RFC in ERP

    Hello Experts,
    I need suggestion on one problem we are facing.
    From ERP we have 3 application which uses Synchronous message call to PI system from where the call is sent to a mainframe system and returned.
    All these 3 applications uses a registered server program XXX_TCP_YY RFC call to connect to PI system.
    In this RFC XXX_TCP_YY the gateway host is mentioned as ERP system and there is a communication channel in PI where this RFC details are maintained.
    After upgrading our ERP 6.0 to EHP 5 we are continuously getting issues with message flow to PI or call to PI is failing and this RFC is taking long time or sometime timing out.
    In such cases since it production i go a restart the channel in PI and this RFC start working fine.
    But i am not sure how to resolve this issue.
    Can you please provide some pointer in which direction i should investigate this problem.
    Regards
    Ajay Sandal

    Hi Ajay,
    Can you check the PI Communication polling interval and whether this restart needed on all the apps or just CI?
    In addition to polling interval please check the SeeBurger services from /nwa and see if the needed on are active.
    Before restarting the channel, clear the cache using full mode too.
    Check this forum link: all Communication Channels stopped or startet when restart of the SAP-PI
    Regards,
    Ashutosh
    Edited by: Ashutosh.Pandey on Jan 11, 2012 9:21 PM

  • Registration of a Server Program in SAP Gateway

    Hello Everybody,
    Everyday while checking logs using T-Code SM21 I am getting the following error log and its description are as follows:
    R49 Communication error, CPIC return code 002, SAP return code 679
    R64 > CPI-C function: CMINIT(SAP)
    Details
    Recording at local and central time........................ 01.02.2008 02:36:28
    Task................ 04756 / Background Processor No. 14
    User................ HSSP1681
    Client.............. 000
    Terminal............
    Session............. 1
    Transaction code....
    Program name........ RSLDAGDS
    Problem class....... K SAP Web AS Problem
    Development class... STSK
    Further details for this message type
    Module name......... thxxcpic
    Line................ 3594
    Error text.......... 002679
    Caller.............. ThCPICS
    Reason/called....... CPIC-Er
    Documentation for system log message R4 9 :
    A CPIC function has failed. The conversation ID and CPIC function are
    specified in the system log entries. Use the conversion ID to find
    more detailed information about the error in the system log for the SAP
    gateway.
    Technical details
    File................ 000011
    Position............ 0000134100
    Entry type.......... m ( Error (Function,Module,Row) )
    Message ID.......... R4 9
    Variable parts...... 002679 ThCPICSCPIC-Erthxxcpic3594.
    I had also referred the notes 353597 and 63930.
    I had also Registered the Server Program :RSLDAGDS in SAP Gateway using T-Code: SM59 but while doing test connection it shows the following Error:
    Connection error Error opening an RFC connection.
    Detail Description of Error:
    ERROR program RSLDAGDS not registered
    LOCATION SAP-Gateway on host saptrng / sapgw00
    DETAIL TP RSLDAGDS not registered
    COMPONENT SAP-Gateway
    COUNTER 778
    MODULE gwr3cpic.c
    LINE 1609
    RETURN CODE 679
    SUBRC 0
    RELEASE 640
    TIME Fri Feb 01 09:35:19 2008
    VERSION 2
    Please suggest the solution and steps to solve the above mentioned Error in my Development System.
    Thanks and Regards,
    Ashish Thakkar.

    Hi Vincent,
              I had alreadry referred the Note:353597 and created the RFC connection for program "RSLSAGDS" but while testing the connection it shows the following error:
    ERROR                program RSLDAGDS not registered
    LOCATION             SAP-Gateway on host saptrng / sapgw00
    DETAIL               TP RSLDAGDS not registered
    COMPONENT            SAP-Gateway
    COUNTER              8105
    MODULE               gwr3cpic.c
    LINE                 1609
    RETURN CODE          679
    SUBRC                    0
    RELEASE              640
    TIME                 Mon Feb 04 02:43:46 2008
    VERSION              2
    I wanted to know what should I define in Program ID while creating a connection for program "RSLDAGDS" as in my System only registered Program ID is IGS.SBX.
    Thanks and Regards,
    Ashish Thakkar.

  • Keeping a server program on

    Hello,
    First of all, I'm not sure this is related to Java at all, so don't be angry if it indeed does not.
    Anyway, I have a simple server program (written in Java) that I'm trying to run on a Linux system, which I connect from home using SSH.
    The problem is that after I close the session (connection) to the Linux server, my program also terminates, while I want it to be operating all the time, not only when I'm connected to the server!
    This does not happen with other programs I have run in the past which were not written by me (such as MySQL database server).
    Does anyone have any idea why this is happening and how to solve it?
    Thanks very much.

    Well given only that, I would argue that your program will never end. However, there's a number of ways to break out of that loop. I'm going to go ahead and make the assumption that either an Exception is being thrown, something inside the loop is returning or breaking out of the loop, or System.exit() is called, or something...

  • HT201487 i have a problem with xcode programming app when i lunch to it it asking me to enter my password and when i enter it the program show that it is wrong but am 100% sure it's wright so please help me with this issue thanks

    i have a problem with xcode programming app when i lunch to it it asking me to enter my password and when i enter it the program show that it is wrong but am 100% sure it's wright so please help me with this issue thanks

    That's not very intuitive
    Check your mail server setup (mail>preferences>accounts>) choose your MobileMe account and select Outgoing Mail Server (SMTP) dropdown box, select Edit SMTP server list, verify that each instance of the me server has a password, if there are more than one and you only have one account then delete the one without a password.

Maybe you are looking for

  • Error : While transporting hedge management in T.Code TEM20

    Hi Guys,      I'm getting runtime error that is " Express document "Update was terminated" received from author "User Name". while tranfering the data to hedge management using the Transaction code TEM20. Error : Short text     The ABAP/4 Open SQL ar

  • Having a field navigable but not editable?

    I have a one field block that displays three records at a time. I have a popup menu associated with the field. The popup calls a form that will populate the field. It populates the record in the block from where the user called the popup (if the user

  • Saving from CS3 to MX

    Hello all, I am currently in an animation class in my senior year of HS. We're working on a pretty big animation but our school only has Flash MX and i have CS3 on my mac at home. I have the file here from school and i can open it perfectly fine, but

  • How to setup RSH on Mac OS X?

    I need to use rsh to execute a command on a remote Mac. I know SSH is available but I need to use RSH. I already created a ~/.rhosts file and edited the /etc/hosts.equiv file. The Firewall has all ports open. Every time a run "rsh [host] [command]" I

  • Bootcamp Win 7 - system restore failure due to missing drivers

    brand new MacBookAir6,2 Intel Core i7 MacOS 10.9 Installation of Win 7 prof. 64bit via bootcamp (no problems) I ran a back-up of the system over my network and then tried a restore. This fails due to the fact that upon invoking the restore option wit