Binary Socket Connection Interruption? bytes lost?

Hi,
I am starting with a short introduction: I am currently working on a project, which involves a server application written in .NET (C#) and a flash gui app as client (standalone flash player 10 [code is written in Actionscript 3.0]). The server constantly sends bitmaps to the client (up to 30fps). The connection is established using binary sockets and data ist streamed to avoid socket open/close/reconnection problems.
The bitmaps sent to the client are marked with begin- and end-tags. A length field was added as well, to optimise the following parsing process. The client buffers the received data up to the point where an end-tag is found. The client reassambles the bitmaps on the screen by parsing the current buffer. Parsing means looking for begin-tags and length fields and/or end-tags of pictures packages. The resulting bitmap data is copied into a byte array and will loaded into a movieclip using the flash.display.Loader class ( bytePictureLoader.loadBytes( byteArray ); ).
Basically looks/works like this:
[SERVER]--->[BEGIN-TAG][LENGTH][BITMAPDATA][END-TAG]-[BEGIN-TAG][LENGTH][BITMAPDATA][END-T AG]-...--->[CLIENT]
While testing, I found out that in some cases the data stream becomes currupted, i.e. data is lost and/or the transmittion is incomplete.
A good thing is that this error is reproducable.
It seems that as soon as the Flash Application Window is dragged (moved on Windows Desktop) the stream lacks data.
The same error occurs, if too much data is sent to the client. The results are performance problems, data loss and other strange effects. The more data is sent on the stream, the more data has to be parsed and the more data gets lost somehow. Sometimes this leads to a memory problem, because Begin- and End-Tags aren't transmitted correctly. In order to fix (counteract) that, I discard data as long as there is no Begin-tag found and the buffer is cleared when the size exceeds 1Mb.
It works so far, but the application lacks performance and stability.
I.e. If 20 bitmaps per second with 620x390px are sent to the client, the client only receives 16 to 17 bitmaps, if the application does nothing else.
If 30 bitmaps per second with 620x390px are sent to the client, the client only receives about 20 to 21 bitmaps.
I am wondering, if there is actually a better solution the solve this problem.
I am guessing that using actuall video streams would be better, then sending one bitmap at a time in a byte stream.
Is there a proper example on how to build a client app in flash to receive/parse a binary data stream??
Does anyone else has recognized the lost-data problem or the interruption of streams?? And is there a solution to this problem?
thanks a lot for your attention hope you can help me out here!
cu
Tobi

Hi Hakan,
thx, but this doesn't work. I think flash struggels with the amount of data to parse. I tested sending images twice, but now i receive only 9 to 12 bitmaps out of 25 bitmaps sent.
Strange thing is, the problem only occurs if the flash player is maximised. As soon as I minimize the flash player window, the parsing works fine, but the image is not being loaded. Guess that's a performance feature of the flash player to not render actuall screen elements as long as the windows window of the flash player is not visible.

Similar Messages

  • How do I transfer files verbatim across a socket connection?

    So, I've got this socket connection running between two computers. I want one computer to take a file (C:\SourceFile.doc for example) and transfer it verbatim over an Internet connection to another computer (C:\DestFile.doc for example). By verbatim, I mean bit for bit, no changes to the format. It would seem that a filereader/filewriter system would work, and it does fine for .txt or plain files, but if I try to do something fancy, like a Microsoft word document (.doc) it doesn't work. Specifically, it saves a bunch of garbage at the begging and end of the file. How do I correct this?
    From my file transmitter:
    out.println("Prepare for Text File");
    FileReader localin = new FileReader(file);
    int l=0;
    while((l=localin.read())!=-1)
         //System.out.print((char)l);
         out.print((char)l);
    localin.close();
    out.println("End Of File");
    From my file reciever
    if(line.equals("Prepare for Text File"))
         System.out.println("ready for text");               if(fileChooser.showSaveDialog(RadioComReciever.this)==JFileChooser.APPROVE_OPTION)
    File localFile=fileChooser.getSelectedFile();
              FileWriter localout = new FileWriter(localFile);
              line=in.readLine();
              while(!line.equals("End Of File"))
                   for(int i=0;i<line.length();i++)
                   {                                                                 localout.write((byte)line.charAt(i));
                   localout.write('\n');
                   System.out.println();
                   line=in.readLine();
              localout.close();
    Thanks for any help!

    But my program is already accessing text from a
    socket connection. Is there a way to transfer things
    over sockets other than text?Yes. Everything that goes over a socket connection is bytes. Certainly you can transfer text, because it can be represented in bytes, but not all files are text. So just send the bytes as is.
    Don't get me wrong, I'm thankful for you help, I just
    thought scokets mostly transfered just text. Am I
    wrong?I don't have any statistics on how much Internet traffic is text. But 100% of it is bytes. Just send the bytes as is.
    And is it just me, or is the documentation on File
    I/O provided by Sun somewhat lacking?It isn't the job of the documentation to explain basic Java concepts like the difference between byte and char. That's the job of the tutorials. Like the Java I/O tutorial.

  • Lost data on socket connection!

    Hi all,
    I have opened a socket connection with another pc, I pass it some parameters and in case of error it send back to me a big number of informations. The problem is: some informations are lost, in particular the first that is "code error", are there some ways to catch all informations with nothing loss?
    Thanks!!!

    Yes, it is possible to use sockets without losing information. In fact, getting all information trough with no loss is the normal behavior of sockets, and the behavior you get must be because of errors in your code.

  • Connect to POP server using Binary Sockets

    Hi there,
    I've just been following the (as of today) latest tutorial on
    http://www.gotoandlearn.com
    about "Binary Sockets" and this all works fine and dandy using
    "leebrimelow.com, 110" for the socket connection (full code below).
    But when I try my own domain "storm-media.co.uk, 110" I get
    the following error message....
    Error #2044: Unhandled IOErrorEvent:. text=Error #2031:
    Socket Error.
    at Pop3_fla::MainTimeline/frame1()
    But if I try using my own gmail account "gmail.com, 110" (or
    "googlemail.com, 110") nothing happens? It just sits there and
    doesn't do anything?
    Any ideas?
    Thanks in advance!
    Kind regards,
    M.

    Thanks for the reply, I changed it to pop3.storm-media.co.uk
    and I managed to connect to the pop server.
    But now I'm onto the next stage of my problem.
    When I run the below code I get a response back from the
    server that says...
    +OK POP3 server ready
    <112d3161-ee1b-4535-a82e-ff63a1d3075a>
    ...but after that nothing happens, even though I'm sending
    another command (in this case my username) to the server to respond
    to?
    Any ideas why the server would not be sending a response?
    My updated code is attached.
    Many thanks for your help so far.
    Kind regards,
    M.

  • Connection Interrupted, Connection to server lost at ID

    Hello Experts,
    I have a crazy issue, as and when I logon to Integration Directory on my personal system, and try to create a Communication Channel under Business Service. It pops up the following error
    Connection Interrupted
    Connection to server lost
    You can login once the server is available again
    Do you want to log on again?
    But when I login again it saysu2026
    Reconnection to server was successful. Repeat the action.
    And when I retry to create the Communication channel the same error reoccurs and continues in the same fashion,
    Same case happens when I try to import a Business System to ID from SLD.
    Thanks
    sk

    Hi Satya,
    And when I retry to create the Communication channel the same error reoccurs and continues in the same fashion,
    Same case happens when I try to import a Business System to ID from SLD.
    I guess this patch might help you in getting rid of the connection dropping error. Get in touch with your basis folk for implementing this patch.
    Else go to -
    http://service.sap.com/nw2004s  -> Support Package Stacks Information
    for the implementation guide and the detailed steps are mentioned there.
    Hope this helps.
    Regards,
    Neetesh

  • Is there any way to identify the particular socket connection is closed ?

    Is there any way to identify the particular socket connection is closed or not ?
    Any methods ???
    How can the program knows the connection is lost or some thing ...
    Is the socket throws some excpetions when there is no active connection ???
    namanc

    If you get an IOException when you try to use the socket, the connection was obviously closed.
    The correct way for an application to know if the socket was closed is:
    1) the server sends a message indicating that the socket should be closed
    2) the client closes the socket itself

  • How to make a socket connection timeout infinity in Servlet doPost method.

    I want to redirect my System.out to a file on a remote server (running Apache Web Server and Apache Tomcat). For which I have created a file upload servlet.
    The connection is established only once with the servlet and the System.out is redirected to it. Everything goes fine if i keep sending data every 10 second.
    But it is required that the data can be sent to the servlet even after 1 or 2 days. The connection should remain open. I am getting java.net.SocketTimeoutException: Read timed out Exception as the socket timeout occurs.
    Can anyone guide me how to change the default timeout of the socket connection in my servlet class.
    Following is the coding to establish a connection with the Servlet.
    URL servletURL = new URL(mURL.getProtocol(), mURL.getHost(), port, getFileUploadServletName() );
    URLConnection mCon = servletURL.openConnection();
    mCon.setDoInput(true);
    mCon.setDoOutput(true);
    mCon.setUseCaches(false);
    mCon.setRequestProperty("Content-Type", "multipart/form-data");
    In the Servlet Code I am just trying to read the input from the in that is the input stream.
    public void doPost(HttpServletRequest req, HttpServletResponse res)
    throws ServletException, IOException
    BufferedInputStream in = new BufferedInputStream(req.getInputStream());
    byte [] content = new byte[1024];
    do
    read = in.read(content, 0, content.length);
    if (read > 0)
    out.write(content, 0, read);
    I have redirected the System.out to the required position.
    System.setOut(........);
    Can anyone guide me how to change the default timeout of the socket connection in my servlet class.

    I am aware of the setKeepAlive() method, but this can only used with the sockets. Here i am inside a servlet, have access to HTTPServletRequest and HTTPServletResponse and I don't know how to get access to the underlying sockets as the socket handling will be handled by the tomcat itself. If I am right there will be method in the apache tomcat 6.0.x to set this property. But till now I am not getting it.

  • Establishing a socket connection between a .swf file and a socket-test program (TCP/IP builder - Windows), in AS3.

    I have an issue with a college project I'm working on.
    Using Actionscript 3, I made a simple .swf program, an animated, interactive smiley, that 'reacts' to number inputs in a input-box.
    For the sake of the project, I now need to make the framework for establishing a socket connection with the smiley .swf, and another program.
    This is where I encounter issues. I have very little knowledge of AS3 programming, so I'm not certain how to establish the connection - what's required code-wise for it, that is.
    To test the connection, I'm attempting to use the "TCP/IP builder" program from windows, which lets me set up a server socket. I need to program the .swf file into a client - to recognize it, connect to it, then be able to receive data (so that the data can then be used to have the smiley 'react' to it - like how it does now with the input-box, only 'automatically' as it gets the data rather than by manual input).
    My attempts at coding it are as follows, using a tutorial (linked HERE):
    //SOCKET STUFF GOES HERE
        var socket:XMLSocket;        
        stage.addEventListener(MouseEvent.CLICK, doConnect); 
    // This one connects to local, port 9001, and applies event listeners
        function doConnect(evt:MouseEvent):void 
        stage.removeEventListener(MouseEvent.CLICK, doConnect); 
        socket = new XMLSocket("127.0.0.1", 9001);   
        socket.addEventListener(Event.CONNECT, onConnect); 
        socket.addEventListener(IOErrorEvent.IO_ERROR, onError); 
    // This traces the connection (lets us see it happened, or failed)
        function onConnect(evt:Event):void 
            trace("Connected"); 
            socket.removeEventListener(Event.CONNECT, onConnect); 
            socket.removeEventListener(IOErrorEvent.IO_ERROR, onError); 
            socket.addEventListener(DataEvent.DATA, onDataReceived); 
            socket.addEventListener(Event.CLOSE, onSocketClose);             
            stage.addEventListener(KeyboardEvent.KEY_UP, keyUp); 
        function onError(evt:IOErrorEvent):void 
            trace("Connect failed"); 
            socket.removeEventListener(Event.CONNECT, onConnect); 
            socket.removeEventListener(IOErrorEvent.IO_ERROR, onError); 
            stage.addEventListener(MouseEvent.CLICK, doConnect); 
    // Here, the flash tracks what keyboard button is pressed.
    // If 'q' is pressed, the connection ends.
            function keyUp(evt:KeyboardEvent):void 
            if (evt.keyCode == 81) // the key code for q is 81 
                socket.send("exit"); 
            else 
                socket.send(evt.keyCode); 
    // This one should handle the data we get from the server.
            function onDataReceived(evt:DataEvent):void 
            try { 
                trace("From Server:",  evt.data ); 
            catch (e:Error) { 
                trace('error'); 
        function onSocketClose(evt:Event):void 
            trace("Connection Closed"); 
            stage.removeEventListener(KeyboardEvent.KEY_UP, keyUp); 
            socket.removeEventListener(Event.CLOSE, onSocketClose); 
            socket.removeEventListener(DataEvent.DATA, onDataReceived);
    Trying to connect to the socket gives me either no result (other than a 'connection failed' message when I click the .swf), or the following error:
    Error #2044: Unhandled securityError:. text=Error #2048: Security sandbox violation: file:///C|/Users/Marko/Desktop/Završni/Flash%20documents/Smiley%5FTCP%5FIP%5Fv4.swf cannot load data from 127.0.0.1:9001.
        at Smiley_TCP_IP_v4_fla::MainTimeline/doConnect()[Smiley_TCP_IP_v4_fla.MainTimeline::frame1:12] 

    Tried adding that particular integer code, ended up with either errors ("use of unspecified variable" and "implicit coercion") , or no effect whatsoever (despite tracing it).
    Noticed as well that the earlier socket code had the following for byte reading:
    "sock.bytesAvailable > 0" (reads any positive number)
    ...rather than your new:
    "sock.bytesAvailable != 0" (reads any negative/positive number)
    Any difference as far as stability/avoiding bugs goes?
    So then, I tried something different: Have the program turn the "msg" string variable, into a "sentnumber" number variable. This seemed to work nicely, tracing a NaN for text (expected), or tracing the number of an actual number.
    I also did a few alterations to the input box - it now no longer needs the 'enter' key to do the calculation, it updates the animation after any key release.
    With all this considered and the requirements of the project, I now have a few goals I want to achieve for the client, in the following order of priority:
    1) Have the "sentnumber" number variable be recognized by the inputbox layer, so that it puts it into the input box. So in effect, it goes: Connect -> Send data that is number (NaN's ignored) -> number put into input box -> key press on client makes animation react. I optionally might need a way to limit the number of digits that the animation reacts to (right now it uses 1-3 digit numbers, so if I get sent a huge number, it might cause issues).
    - If the NaN can't be ignored (breaks the math/calculus code or some other crash), I need some way of 'restricting' the data it reads to not include NaN's that might be sent.
    - Or for simplicity, should I just detect the traced "NaN" output, reacting by setting the number variable to be "0" in such cases?
    2) After achieving 1), I'll need to have the process be automatic - not requiring a keyboard presses from the client, but happening instantly once the data is sent during a working connection.
    - Can this be done by copying the huge amounts of math/calculus code from the inputbox layer, into the socket layer, right under where I create the "sentnumber" variable, and modifying it delicately?
    3) The connection still has some usability and user issues - since the connection happens only once, on frame 1, it only connects if I already have a listening server when I run the client, and client can't re-connect if the server socket doesn't restart itself.
    I believe to do this, I need to make the connection happen on demand, rather than once at the start.
    For the project's requirement, I also need to allow client users to define the IP / port it's going to connect to (since the only alternative so far is editing the client in flash pro).
    In other words, I need to make a "Connect" button and two textboxes (for IP and port, respectively), which do the following:
    - On pressing "Connect", the button sets whatever is in the text boxes as the address of the IP and port the socket will connect to, then connects to that address without issues (or with a error message if it can't due to wrong IP/port).
    - The connection needs to work for non-local addresses. Not sure if it can yet.
    - On re-pressing connect, the previous socket is closed, then creates a new socket (with new IP/port, if that was altered)
    It seems like making the button should be as simple as putting the existing socket code under the function of a button, but it also seems like it's going to cause issues similar to the 'looping frames' error.
    4) Optional addition: Have a scrolling textbox like the AIR server has, to track what the connection is doing on-the-fly.
    The end result would be a client that allows user to input IP/Port, connects on button press (optionally tracking/display what the socket is doing via scrollbox), automatically alters the smiley based on what numbers are sent whilst the connection lasts, and on subsequent button presses, makes a new connection after closing off the previous one.
    Dropbox link to new client version:
    https://www.dropbox.com/s/ybaa8zi4i6d7u6a/Smiley_TCP_IP_v7.fla?dl=0
    So, starting from 1), can I, and how can I, get the number variable recognized by "inputbox" layer's code? It keeps giving me 'unrecognized variable' errors.

  • Mobile-Desktop socket connection

    I have a client program running on a mobile and a server program running on my desktop, I am trying to establish a socket connection between them and send "hello" message from the mobile to the desktop, here are the codes
    Client:
    try{
    SocketConnection sc = (SocketConnection)
    Connector.open("socket://xxx.xxx.xxx.xxx:4444");
    myDisplay.setCurrent(form);
    OutputStream os = null;
    try{
    os = sc.openOutputStream();
    byte[] data = "Hello/".getBytes();
    os.write(data);
    os.flush();
    } finally{
    sc.close();
    os.close();
    } catch (IOException x){
    x.printStackTrace();
    }Server:
    public void Server()
    ServerSocket serverSocket=null;
    Socket clientSocket = null;
    try {
    serverSocket = new ServerSocket(4444);
    clientSocket = serverSocket.accept();
    } catch (IOException e) {
    System.out.println("Could not listen on port: 4444");
    System.exit(-1);
    System.out.println("Connection Established");
    try
    char[] input=new char[1000];
    int i=0;
    char delimiter='/';
    InputStream in=clientSocket.getInputStream();
    while ((input=(char)in.read()) != delimiter){
    System.out.println(input[i]);
    i++;
    in.close();
    clientSocket.close();
    serverSocket.close();
    }catch(IOException e)
    e.printStackTrace();
    }I run the server then I run the client, "Connection Established" message appeares indicating that the desktop successfully accepted the connection request from the mobile, however, the "Hello" message doesn't appear afterwards, nothing appeares after the "Connection Established" message actually, So what has gone wrong?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    You will find that using Sockets with MIDP is going to be hard work for you. (different phones different behavior, and many network providers do all sorts of funny firewalling).
    Are you able to use HTTP instead? E.g. XML over http.

  • Socket connections on LAN?

    I am designing a java application which will have 100 clients and a database server over LAN. There is no application server, only core java is used to write the programming logic. Now, to read, update or write anything to the database a bare socket connection will be made by the client to the server over LAN. Please tell me is it safe to perform this kind of communication? Will the network connection sustain for a long time or there are many chances that it may break easily? In no case will I be able to use an application server. Can I design such an application that communicates through bare sockets with no protection as such?

    If you use stream sockets your connection will survive for long periods of time. I have an application that connects to a mainframe by sockets and to Oracle using OCI (which uses sockets) that stays up for a week at a time, only stopping when the mainframe goes down for weekly maintenance. It recovers when the mainframe restarts by attempting to reconnect once a minute.
    This said, you still should deal with the inevitable situation where the connection is lost due to network problems or aproblemon your server.

  • Socket connection between Java and C

    I want to establish socket connection between Java client and C server (on Unix). Can anybody tell how to do it? Will the socket created in client be available in server. I tried out but there was no response from the server.

    We too can't connect the daemon server written by "c". The phenomena is below.
    << Execution of this Question1.class >> ---------------------------------------
    [kazuyuki@CryptOne tmp]$ java Question1 E 1.2.3.4 MFrame.java 195.211.1.1 15021
    << Output message >> ----------------------------------------------------------
    Quetion1 : flg_ = E
    Quetion1 : key_ = 1.2.3.4
    Quetion1 : fn_ = MFrame.java
    Quetion1 : adr_ = CryptOne.localhost/195.211.1.1
    Quetion1 : port_ = 15021
    java.net.ConnectException: Connection refused
         at java.net.PlainSocketImpl.socketConnect(Native Method)
         at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:350)
         at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:137)
         at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:124)
         at java.net.Socket.<init>(Socket.java:268)
         at java.net.Socket.<init>(Socket.java:122)
         at Question1.UPLOAD(Question1.java:65)
         at Question1.main(Question1.java:155)
    << Question >> ----------------------------------------------------------------
    Why the event "java.net.ConnectException: Connection refused" has occured ?
    The server to connect from Question1 can accept the connection request from
    the client program coded by "c" program. We have written down the daemon server
    program by "c" code tcp/ip socket functions (socket, bind, listen, accept).
    Security manager admits the access from this Question1.class, we have checked.
    Would you like please answer this Connction refuse occurrence ?
                                                                     2002.05.18 11:50:00.0(JST)
                                                                     K.Masuda
    << Java client code>> -------------------------------------------------
         (c)Copyright     All rights reserved.
              K.Masuda     2002.05.18
                   << Question1.java >>
    import     java.lang.String;
    import     java.io.InputStream;
    import     java.io.OutputStream;
    import     java.io.DataInputStream;
    import     java.io.DataOutputStream;
    import     java.io.FileInputStream;
    import     java.io.FileOutputStream;
    import     java.io.IOException;
    import     java.io.FileNotFoundException;
    import     java.net.Socket;
    import     java.net.InetAddress;
    import     java.net.UnknownHostException;
    import     java.net.ConnectException;
    import     java.net.NoRouteToHostException;
    class Question1 {
         char               flg_;
         String               key_;
         String               fn_;
         InetAddress          adr_;
         int                    port_;
         Socket               sock_;
         Question1(
              char          flg,
              String          key,
              String          fn,
              String          adr,
              int               port
              flg_     = flg;     
              key_     = key;
              fn_          = fn;
              try{
                   adr_     = InetAddress.getByName( adr );
              catch( UnknownHostException e ){
                   e.printStackTrace();
              port_     = port;
    System.out.println( "Quetion1 : flg_ = " + flg_ );
    System.out.println( "Quetion1 : key_ = " + key_ );
    System.out.println( "Quetion1 : fn_ = " + fn_ );
    System.out.println( "Quetion1 : adr_ = " + adr_ );
    System.out.println( "Quetion1 : port_ = " + port_ );
         public void UPLOAD(
              try{
                   sock_     = new Socket( adr_, port_ );
                   UpLoad();
                   DnLoad();
                   sock_.close();
              catch( UnknownHostException e ){
                   e.printStackTrace();
              catch( ConnectException e ){
                   e.printStackTrace();
              catch( NoRouteToHostException e ){
                   e.printStackTrace();
              catch( IOException e ){
                   e.printStackTrace();
         public void UpLoad(
              byte[]                         buf          = new byte[ 512 ];
              int                              rlen;
              int                              wlen;
              try {
                   OutputStream          sos          = sock_.getOutputStream();
                   FileInputStream          fis          = new FileInputStream( fn_ );
                   DataInputStream          dis          = new DataInputStream( fis );
                   DataOutputStream     dos          = new DataOutputStream( sos );
                   while( ( rlen =     dis.read( buf, 0, buf.length ) ) >= 0 ){
                        dos.write( buf, 0, rlen );
                   dis.close();
                   dos.close();
                   fis.close();
                   sos.close();
              catch( IOException e ){
                   e.printStackTrace();
         public void DnLoad(
              byte[]                         buf          = new byte[ 512 ];
              int                              rlen;
              int                              wlen;
              try {
                   InputStream               sis          = sock_.getInputStream();
                   FileOutputStream     fos          = new FileOutputStream( fn_ + ".cry" );
                   DataInputStream          dis          = new DataInputStream( sis );
                   DataOutputStream     dos          = new DataOutputStream( fos );
                   while( ( rlen =     dis.read( buf, 0, buf.length ) ) >= 0 ){
                        dos.write( buf, 0, rlen );
                   dis.close();
                   dos.close();
                   fos.close();
                   sis.close();
              catch( IOException e ){
                   e.printStackTrace();
         public static void main(
              String[] args
              char[]     chrs     = ( new String( args[ 0 ] ) ).toCharArray();
              Question1     clnt     = new Question1(
                                                                     // E or D
                                            chrs[ 0 ],
                                            args[ 1 ],               // key string
                                            args[ 2 ],               // file to be processed
                                            args[ 3 ],               // IP address
                                                                     // port
                                            Integer.parseInt( args[ 4 ] )
              clnt.UPLOAD();
    }

  • Persistent socket connection - socket write error

    I'm connecting to a server using sockets. My application acts like a client, sending requests, and also like a server, listenning for notifications. I was using a client socket for the first task (send a message when required) and a server socket for the second (permanently listen for incoming messages). This needs to be some kind of persistent connection.
    It happens now I'm required to send and receive using the same port. The only way I found to do this is to have a single socket (client) bound to a certain port. It connects to the server and one thread keeps listenning for incoming messages (by reading the input stream) while another process is launched whenever I need to send a message (by writing to the socket's output stream). The socket is created only once (when the application starts) and its output/input streams reused whenever needed.
    This works well for a while. However, when I try to send a message after some idle time (lets say 20 minutes) strange things happen. The first attempt to send a message returns success (although nothing is actually received by the server). The second attempt returns java.net.SocketException: Software caused connection abort: socket write error. I don't understand this behaviour. Can there be a timeout? I only write to the socket after testing if it's connected.. So why is this failing? Also, any other ideas on how to send and receive using the same port? A different and better approach maybe..
    Thanks in advance

    Socket.isConnected just tells you whether you have personally called Socket.connect() or new Socket(host, port,...). It doesn't tell you anything about the state of the connection.
    You should certainly issue periodic application 'pings' at suitable intervals, and many application protocols do this. For example, Java RMI reuses connections that are less than 15 seconds old but only if they pass a ping test.
    In general however you can't insist on a persistent connection over TCP/IP, especially if you have this kind of hardware in the circuit. What you can do is recognize when the connection has been lost and form a new one. The network is going to fail somewhere some time and your program has to be robust against that.

  • Problem: Socket connection is not creating in machine, through utility program (MFC Dll), on ListDisplay service port - 3334 (on separate machine), while we are able to telnet on same ListDisplay service port - 3334 from same issue machine on same time

    Problem: Socket
    connection is not creating in machine, through utility program (MFC Dll), on ListDisplay service port - 3334 (on separate machine), while we are able to telnet on same ListDisplay service port - 3334 from same issue machine on same time
    Environment: -
    OS:
    Windows XP SP2/7
    Code:
    VC 6.0
    Dll: MFC
    Problem Description: -
    We have written a utility program which create socket (Using windows standard method [MFC]), and then make connection with another service (List Display) running
    on port 3334 in different machine and retrieve the required list data. This program was working fine in almost all the machines.
    But, we have received a severe intermittent issue on two machines. Client is facing issue in displaying the list data from port 3334.
    Attempt: -
    First we tried to debug code, and we come to know that socket is not creating in utility program. So we tried to telnet on ListDisplay service port 3334 and we were surprised that we were able to telnet, then we opened some more
    telnet window on same port 3334 around (6 to 8) window, and each cmd connected properly. But we were not able to create socket from utility program.
    Problem is severe because issue is intermittent.
    We have tried all the way, but we are not able to figure it out, that what can be the exact problem and what are the conditions, when utility program will not
    connect with ListDisplay service on port 3334.
    Kindly assist to resolve this issue. For any help, we would be really thankful.

    Hi,
    According to your description, it seems that you have created an utility program which is making connection with another service port 3334, however, two clients are facing issue in display the data list from port 3334.
    Port: 3334/TCP
    3334/TCP - Known port assignments (1 record found)
    Service
    Details
    Source
    directv-web
    Direct TV Webcasting
    IANA
    Since the port 3334 is used by directv-web service, I'd like to suggest check this service it is working well on the problematic clients.
    1. The client can be resolved in DNS well? Please run "nslookup" in the prompt command.
    2. Is there any 3rd party application interrupting? Do test in clean boot.
    2. Strongly suggest you run process monitor tool to analysis it.
    I am looking forward to your reply if you have any updated on your side.
    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

  • Integration Directory - Server Connection interrupted

    Hi,
    after a system copy we have the following problem: If we start the "Integration Builder:Configuration" and want to view, create or change an object we lost the server connection. The error message in a popup is: "Connection Interrupted. Connection to sercer lost. You can log again once the server is available again. Do you want to log on again?" After the log on again and a new click of an object to view or change it, the same error pops up.
    What can i do?
    Kind regards, Norbert

    Hi,
    the problem exists only in the integration directory. In "Integration Builder: Design (Integration repository)"  there are no problems with viewing and changing objects. Also my user login is not locked due to invalid login attempts.

  • Server connections interrupted??

    I've tried to get the proper forum, sorry if wrong.
    I was surfing on my macbook air when all of a sudden I get this 'pop-up' that looks like an Alert(?): A yellow triangle with an exclamation mark in it and it says: "Server Connections Interrupted" and below a picture of maybe a light blue 'book' with three white 'men' (figures) in it and next to it it said 'SharedDocs' and under that 'Owner', then I had the option of clicking either: 'Ignore' or 'Disconnect All' and lastly a 'eject' type of symbol
    But I never lost service, was I being hacked???I have a secure wi-fi
    I clicked the 'eject' type 'thing' and it went away....
    signed nervous

    I may be having this problem on my server. I have leopard on the router and tiger still on AFP on the internal server until I get time to upgrade. But I am not actually losing the connection. It just says that it is interrupted. This has gotten much worse lately.

Maybe you are looking for

  • Why is it taking so long to type in a text?

    It seems everything on my phone is really slow all of a sudden.

  • Moving object w/shift key no longer aligns in straight line (or 45)

    AICS5 Mac OS 10.6.5 Worked fine up until today. If I try to move an object with the shift key held down, object moves all over as if the key were dead. Is there a preference I disturbed? Shift key certainly works otherwise.

  • Preview screen shows own desktop

    on my g4 laptop i am able to receive video and sound but my preview window is showing my own desktop (and as it is showing my own desktop there is a regression like two opposing mirrors withinn this window). My buddy sees this image but can hear me o

  • Exporting from Avid to use in FCP

    I have a personal project that I edited on an Avid, but want to export the sequences as Quicktime files to use as source material to finish on FCP 5.0, then author a DVD on iDVD. It's for personal use, so it doesn't have to be flawless, but I want it

  • MYSQL query help..... [SOLVED -- myself -- two min later]

    Ok, I've got a table like this: style     color     size 145       red       s 145       red       m 145       red       l 145       blue      s 145       blue      m 150       red       s 150       red       m etc etc....there is also a sku field as