Socket communication failure between Java applet and C++ application

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

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

Similar Messages

  • Difference between Java applet and JavaFX

    Hello, all!
    I am studying javaFX in general. As far as I understand there is no main difference between java applet and javafx, except javafx has different syntax and library simple to use. Is it right?

    Basically, yes. But as you point out, it is supposed to be faster to develop in JavaFX...
    For example, Processing allows to export to applet, and is strong on doing graphics, but to see if user has clicked on a circle, you have to check the mouse coordinates against the circle coordinates, or create your own Circle class: it is at a much lower level.
    Likewise, you can use gaming frameworks like Slick2D or PulpCore, but they might be lacking on GUI (but perhaps faster). Or use Apache's Pivot, strong on GUI, but perhaps lacking a bit on graphics and animation.
    It depends on your needs, if you prefer to stick to Java, etc.

  • Client side event between Java iView and BSP application

    Hi,
    I am developing a BSP iView which listen to event raised by standard SAP HR TeamViewer iView.  The TeamViewer iView raise a event when user click on the employee list. 
    EPCM.raiseEvent { "urn:com.sap.pct.hcm.orgmanagement:CurrentObject", "objectChanged", concatenatedKey);
    My BSP is subscribing to the event and perform the myreceiveEvent function.
    EPCM.subscribeEvent
    ( "urn:com.sap.pct.hcm.orgmanagement:CurrentObject", "objectChanged", myreceiveEvent );
    However, my BSP returns an error message saying that EPCM is undefined.  I know that I have to included the java script file.  I checked with my basis team guy and they said there is not any js file in ICF.  Can someone let me know which file I need to include in my BSP code and where is the file locate?
    Thanks,
    Eric

    Hi Eric,
    > the ICF where the BSP is stored
    > is in the Oracle database
    Eric... the place where the JS fragment - within the BSP - appears, is retrieved by some http request. The script=epcfproxy.js forces the browser to send a http request just to the same relative location the original page came from. Doesn't matter if something is within a database...
    > Do you know how to locate the
    > epcfproxy.js file in the WAS?
    I think:
    > and the epcfproxy.js file is in the zip file
    > that you suggested
    you have found it?! Put it to any place on the BSP server you can access, if you can't set it with relative url, use "/some/.../dir/epcfproxy.js" as location.
    > If I am only EPCM but not EPCMPROXY,
    > do I need to include the epcfproxy.js in my code?
    Have a look at epcfproxy.js. It's no magic at all, you have to call top or parent (just look) and do some minor things. For sure, you can live without the proxy file, you have just to put the neede scripts explicitely on your page, that's not that fine, but it works.
    Hope it helps
    Detlev

  • How to interchange data between Java Program and C++ Program

    I constructed a java program using netbeans IDE that has ability to connect with a respective DLL; I want to connect and interchange data between my java program(.jar) and VSC++ program(.exe) through DLLs.JNI uses single Dll to invoke C/C++ function in native manner,In order to increase the efficiency I tried to connect and interchange primitive data types between Java program and C++ program using that DLL(JNI implemented).
    Unfortunately C++ program cannot obtain data values that has been changed by Java Program.For example - If I declare a global int variable in DLL,java program can catch that int variable and can update it but If I run my C++ program(exe) loading same DLL simultaneously it cannot receive the updated value of that int variable declared in the DLL.
    Therefore I need a solution to share/Interchange at least primitive data and their respective values between a JAVA and C++ Program using JNI (in spite of date transferring through Sockets).JAVA TO C/C++ & C/C++ to JAVA using DLLs.
    (TWO WAY COMMUNICATION)
    JAVA.jar  <=> <JNI> <=> DLL <=> [Connector Program C/C++] <=> C/C++ .exe
    PLEASE HELP ME!! THANK YOU

    What in the are you trying to say? What does "filled into the servlet mean?" Is the map somewhere outside the servlet? In a different process? Are you asking how to extract data from a map? Something else?
    Sorry, but your question makes no sense.

  • Selecting between java.io and java.nio

    Hi,
    I'm a bit confused between java.io and java.nio. What sre the major differences between these two?
    In areas are these best applicable?

    The java.nio package improves on the basic Java I/O that was available prior to JDK 1.4.
    It is designed to interoperate more natively with the underlying file handles (sockets, open files etc) to achieve better performance.
    The improvements include true non-blocking I/O, better buffer management, character-set support, channels (similar to Occam's channels) and selectors, and some other ancillery stuff. Most of these classes are designed to be inherently threadsafe.
    There are some examples here:
    http://java.sun.com/j2se/1.4.2/docs/guide/nio/example/index.html
    However, if you are still a beginner with file or network I/O, its better if you start with the simple I/O first. You'll appreciate the NIO improvements better afterwards.

  • Whats is difference between Java JRE  and  Java SDK

    Hi,
    what is the difference between Java JRE and Java SDK...
    i think both of them have the same set of files to be installed...
    I am not able to understand where they differ

    The JRE (Java runtime Environment) contains just the stuff necessary to run Java and the SDK (System Development Kit) contains the extra stuff necessary (and also helpful) to develop in Java.

  • Compatibility between Java crypto and open ssl

    Hello
    I have some question about compatibility between java crypto and openssl library.
    This is my case:
    1.I created DESede key and stored it to file:
    SecretKey key = KeyGenerator.getInstance("TripleDES").generateKey();
    File f = new File("c:\\key.dat");
    DataOutputStream dos =new DataOutputStream(new FileOutputStream(f));
    dos.write(key.getEncoded());
    dos3.close();2.I encrypt some file "c:\\normal.dat" through:
    ecipher.init(Cipher.ENCRYPT_MODE, key2);
      byte[] enc = ecipher.doFinal(normalData);
      File f2 = new File("c:\\enc.dat");
      DataOutputStream dos =new DataOutputStream(new FileOutputStream(f2));
      dos.write(enc);
      dos.close();

    You have carefully left out some critical java code, namely the Cipher.getInstance() method. You'll notice in the documentation for this method that there 3 components to the "transform" argument of this method, the algorithm, the mode, and the padding. All of these must match exactly with the what openssl is using. Furthermore, if you are using one of the modes which require an IV, like CBC mode, then this must match exactly too. If you don't explicitly specify some of these parameters, you might get default values supplied. It is up to you to find out what these are.

  • I am having one application which i am going to install on my ipad and i am having one external device having USB interface. I want to have communication in between  my device and ipad over USB/BT. is it possible

    My external device is having male USB connector. The cable available in market are having can be plugged to the device having female connector.I will need converter in between as my device is having male connector. Can i get such cable? If yes can i establish communication in between my app and device over these cables.I am not passing any audio/video data or photos.I am sending data frames. My device is having firmware and it sends data frames in firmware understandable format. Let me know can i have two way communication in between over USB/BT?
    Right now i am connecting my device with host PC and i want to replace my host PC with ipad.

    Thanks....
    will it be possible to establish communication in between my device and app. Because camera conection kit only transfers photos and videos and my device doesnt have any audio/video data.
    If yes, should i add photo header to my frames and will send as corrupted photo file or what needs to implement so that i can have sound communication in between.

  • What's the difference between Java SDK and the Enterprise Edition?

    What's the difference between Java SDK and the Enterprise Edition? Are they both free?

    both r free but they are used in diffrent applications. sdk are used for simple apps that run on your computer while j2e (enterprise edition) are ment for large distributed computer systems that include servers and such. if you don't know the diffrence you probably wont need the the j2e, only the sdk.

  • I have a communication error between Lightroom 5 and my printer. It prints photos about 1/2 strength in color. Printer checks out ok. WHAT CAN I DO?

    I have a communication error between Lightroom 5 and my printer. It prints photos about 1/2 strength in color.. The printer checks out ok. What can I do?

  • Communication protocol between Admin Server and Managed Server

    Hello - I am hoping someone can help me here to understand the communication protocols used in my setup.
    Here is my understanding of the protocol that are used between each component.
    End User <--->HTTPS<--->LoadBalancer Device<--->HTTPS<--->Web Server<---->HTTPS<--->WebLogic Server(Managed Server)<--->LDAP/JDBC<-->Data tier components
    AdminServer<--->T3<--->Managed Server i.e. The communication protocol between Admin Server and Managed server is T3
    The communication protocol between Managed Servers running in one cluster on two seperate machine is What?
    Thank you.

    Hello, interesting question.
    In the documentation " [cluster multicast communication|http://download.oracle.com/docs/cd/E13222_01/wls/docs90/cluster/features.html#1007001] " don't specify the used protocol to pack the information for example in a session replication.
    Although in a session replication all objects must be serializable i don't think rmi protocol is used.
    I hope some expert give us some light in this issue :-)
    http://download.oracle.com/docs/cd/E13222_01/wls/docs90/cluster/features.html#1007001

  • Difference between Java class and JavaBean?

    What is the difference between a Java class and a JavaBean?
    A class has variables which hold state.
    A class has methods which can do things (like change state).
    And if I understand a JavaBean it is rather like a BIG class...
    i.e.
    A JavaBean has variables which hold state.
    A JavaBean has methods which can do things (like change state).
    So, what's the difference between the two?
    And in case it helps...What is the crossover point between the two? Is there a minimalist type JavaBean which is the same as a class? What is the difference between Java beans and Enterprise Java Beans?
    Thanks.

    Introspection, as I understand it is a bunch of
    methods which allows me to ask what a class can do
    etc. right? So, if I implement a bunch of
    introspection methods for my class then my class
    becomes a JavaBean?Introspection allows a builder tool to discover a Bean's properties, methods, and events, either by:
    Following design patterns when naming Bean features which the Introspector class examines for these design patterns to discover Bean features.
    By explicitly providing the information with a related Bean Information class (which implements the BeanInfo interface).
    I understand now they are completely different.
    Thanks. Very clear.
    I do not understand how they are completely different.
    In fact I don't have a clue what the differences are
    other than to quote what you have written. In your
    own words, what is the difference? This is the "New
    to Java Technology" forum ;-) and I'm new to these
    things.In that case ejbs are way too advanced for you, so don't worry about it.

  • [svn] 4112: Further work for FXG to SWF transcoding - checking in some work resulting from collaborating with Kaushal to correct FXG transforms and gradient transforms as well as cater for differences between Java AffineTransform and the SWF Matrix type .

    Revision: 4112
    Author: [email protected]
    Date: 2008-11-14 10:05:42 -0800 (Fri, 14 Nov 2008)
    Log Message:
    Further work for FXG to SWF transcoding - checking in some work resulting from collaborating with Kaushal to correct FXG transforms and gradient transforms as well as cater for differences between Java AffineTransform and the SWF Matrix type.
    QE: Not yet.
    Doc: No
    Checkintests: Pass
    Reviewer: Kaushal
    Modified Paths:
    flex/sdk/trunk/modules/swfutils/src/java/flash/fxg/dom/GraphicContentNode.java
    flex/sdk/trunk/modules/swfutils/src/java/flash/fxg/dom/fills/LinearGradientFillNode.java
    flex/sdk/trunk/modules/swfutils/src/java/flash/fxg/dom/fills/RadialGradientFillNode.java
    flex/sdk/trunk/modules/swfutils/src/java/flash/fxg/dom/strokes/LinearGradientStrokeNode.j ava
    flex/sdk/trunk/modules/swfutils/src/java/flash/fxg/dom/strokes/RadialGradientStrokeNode.j ava
    flex/sdk/trunk/modules/swfutils/src/java/flash/fxg/swf/AbstractFXGGraphics.java
    flex/sdk/trunk/modules/swfutils/src/java/flash/fxg/swf/TypeHelper.java
    Added Paths:
    flex/sdk/trunk/modules/swfutils/src/java/flash/fxg/dom/ScalableGradientNode.java

  • Using Java Applet in WebDynpro Application

    Hello,
    I have the problem that I must access the client in my WebDynpro Application.
    But I found no way to include a Java Applet in my application, so my question: Is it generally possible to include a Java Applet or not?
    If it is not possible with an Applet, is there any other way to access the client?
    Thanks a lot

    We actually embed Java applets in our application. But only on the portal.
    Wrap the applet around a BSP.
    Call the URL in an iframe.
    To prevent the reloading problems that we see with applets and actions, we put the applet in a modal window, with an OK button at the bottom so that when applet processing is finished, the rest of the web dynpro functionality resumes.
    If you need to have them both in the same page, you can embed the BSP iview in the same portal page.

  • Run a java applet whitin a application ?

    Is it possible for an application to start a java applet and run it inside the application, say on a Jpanel ?
    Regards
    Per

    Yes. Just remember that it's now you who is responsible for calling init and start.
    (there will be some problems if the applet calls methods like getCodeBase and getParameter)

Maybe you are looking for

  • Incoterms in purchase order should appear only in header.

    Hi All, When the inter company purchase order is created with reference to purchase requistion, in some scenarios the header and item level incoterms are copied in the purchase order. 1. Incoterms in the header level of purchase order are copied from

  • AppleTV - Video Format Not Recognized

    I know this question is out there, but I can't find the answer that helps.   I have one of the Apple TVs that you sync to, not stream, and I've downloaded a bunch of digital workouts that I purchased online.  I've never had a problem playing them bef

  • How to add Jsp pages into existing portal (JDeveloper 9.0.4)

    I am a jsp developer. I have to add a jsp page into existing portal. I am new to portal. Could anyone help me how to develop jsp using portal classes like PortletRenderRequest,ProviderSession and others.

  • Airport Express not being 'seen' after configuration in Windows

    I thought I would start my own thread on this, I had put this as a reply to someone elses before. I have a Gen1 Airport express being used to play music through our stereo system throughout the house. It was working perfectly until I replaced my dead

  • How to assing parameters to select-options

    hi all thanks in advance how to assign parameter value to select-option date SELECTION-SCREEN: BEGIN OF BLOCK B1 WITH FRAME TITLE text-001.   select-options    s_budat     FOR mkpf-budat  OBLIGATORY,                           s_budat1     FOR mkpf-bu