Using non blocking connect() call for SCTP sockets in Solaris10

Hi,
I have a problem with non blocking connect call on SCTP socket.
I am using the sctp stack support in Solaris10.
When the connect is successful, I can get the pollout event on the socket.
But there is no event observed when the peer does not exist. In other words, I could not get the pollout event on connection failure. This logic works fine with TCP sockets on both Solaris and Suse10.
I am working with SCTP one-to-one style sockets.
Is there any way to handle this issue?
Do I need to load any patch to resolve this issue?
It will be great if I get a solution in this regard.
Thanks in advance.
Best Regards,
Bipin.

There are at least two problems here.
A. In the receiver you should test for -1 from the read() immediately, rather than continue with the loop and try to write -1 bytes to the file.
B. In the sender you are ignoring the return value of client.write(), which can be anything from 0 to the buffer length. If you get 0 you should wait for another OP_WRITE to trigger; if you get a 'short write' you need to retry it until you've got nothing left to write from the current buffer, before you read any more data. This is where the data is vanishing.

Similar Messages

  • Using OCIBindDynamic with non-blocking connections

    I need to use an OCI array interface for execute statements more than once per one request to server.
    When I have called stored procedure or function in the non-blocking connection context using OCIBindDynamic for parameter binding, application have been crashed at random time.
    I don't have any problems using default (blocking) mode.
    Environment:
    Oracle 8.1.7 release 3 for Windows
    MS Visual C++ 6.0 compiler
    Could anybody help me ?

    It's always possible in any read that the number of bytes read is less than the number of bytes requested. You need to keep reading until you have got everything you expected, and cope with every possible error condition on each iteration.
    EJP

  • Java.io.IOException: Connection timed out while using non-blocking NIO

    Hi,
    I am using non-blocking NIO on jdk 1.6 to transfer files between two processes. The problem is that the sender thread times out on the write call even though it's in non-blocking mode. It doesn't make sense. The receiver on the other end is running fine, and even tries to read from the socket after the sender drops the connection, and throws a Connection reset by peer exception. I should mention that the receiver is sometimes busy doing other stuff, and may be a second or two late in issuing the read call. But if I understand correctly, default TCP timeout is about 2 minutes, so there's no reason why it should timeout in a second or two. I'd appreciate it if anyone has any insight.
    Thanks!

    No I have definitely completed the connection since I it happens a while after the transfer has actually started and part of the file has already been transferred. Oh btw, I should mention that it doesn't always happen. It's intermittent. And it's not a network issue since iperf tests between the two nodes show nothing unusual.

  • Non-blocking connection on a SocketChannel?

    I'm trying out the non-blocking connection of a SocketChannel. So I wrote the following test code and supply a list of IPs (both good and bad IPs). But disregard the IPs I always get the result of a channel being in connection pending state (even for some bogus IPs). Any help will be great.
    public class ConnectTest
        public static void main(String[] args) throws
    Exception
            List<SocketChannel> channels = new ArrayList<SocketChannel>();
            for ( String s: args )
                SocketChannel channel = SocketChannel.open();
                channel.configureBlocking(false);
                channels.add(channel);        
                InetSocketAddress remote = new InetSocketAddress(s, 80);
                channel.connect(remote);
            System.out.println("wait for timeout...");
            Thread.sleep(10000);
            for ( SocketChannel c : channels )
                if ( c.isConnected() )
                    System.out.println(c.socket().getInetAddress() + " connected ");
                else if ( c.isConnectionPending() )
                    System.out.println(c.socket().getInetAddress() + " connection pending ");               
                else
                    System.out.println(c.socket().getInetAddress() + " timeout ");
                c.close();
    }

    Forget the sleep: use a Selector, selecting on OP_CONNECT. When you get it, call SocketChannel.finishConnect() for the channel(s) selected. If that method returns 'true', the connection is complete. If it returns 'false', the connection is still pending (and in fact OP_CONNECT should not have fired); if it throws an exception, the connection attempt has failed.
    If the connection is complete you must also deregister it for OP_CONNECT before registering it for OP_READ or OP_WRITE.

  • Non-blocking J2EE calls

    We wish to connect fat clients (in our case Powerbuilder) to a J2EE environment (Weblogic). We also need to make some of the calls from the fat client non-blocking (asynchronous). With many clients, JMS was rejected as a mechanism.
    Our first solution, which works as a prototype, was to package a Java bean as an OLE object and deploy it to the client. This bean could make the calls non-blocking. However there are registry issues (the packaging implies a pre-defined directory structure), we need a JRE on every client and 15Mb of weblogic jars (aaargh), so it only really works as a prototype.
    The next (current) solution is a C dll that can be called from Powerbuilder and uses a socket to talk to a Java J2EE Gateway on the server. This Gateway makes the system non-blocking and calls the EJBs. This is clearly easier in terms of configuring the client.
    Ideally we would like to drop the Gateway by finding a non-blocking way to get into J2EE from the C dll but the only methods we have thought of:
    - simulating an HTTP servlet call
    - SOAP
    are synchronous (or appear to be, my knowledge of SOAP is limited).
    Has anyone come across other ways of getting non-blocking communications with J2EE?

    CORBA, this is what it was designed to do, but it is not not a light weight solution.

  • JDK 1.4 nio non-blocking connects don't finish

    I am working with the Linux version of JDK1.4, doing some testing of the
    non-blocking capability. The few tests that I have done have shown some
    strange results:
    - When opening a non-blocking connection to a server which has an
    announcement banner, say such as POP which gives something like:
    +OK pop3 server ready
    then connection seems to be OK and proceed through to completion.
    - When opening a non-blocking connection to a server which is silent, and
    expects me to start the conversation, such as contacting an HTTP server,
    then the Selector.select() never returns to allow me to finish the
    connection.
    Below is a test program which illustrates the problem for me.
    It attempts to open a non-blocking connection to www.yahoo.com on port 80.
    It then drops into a Selector.select() where I am waiting for the chance to
    catch the SelectionKey.OP_CONNECT event and finish connecting, and then send
    a simple HTTP GET request down the wire. That OP_CONNECT event
    never seems to arrive though, and I remain stuck in the select().
    'netstat -na' shows that I am in a connection established state.
    Any insight appreciated,
    -Steve M [email protected]
    ------------------>8 cut here 8<-----------------------
    import java.io.*;
    import java.net.*;
    import java.util.*;
    import java.nio.*;
    import java.nio.channels.*;
    public class NoWorkee
    public static String GET_REQUEST = "GET / HTTP/1.0\r\n\r\n";
        static class Context
            String host;
            int    port;
            ByteBuffer request;
            public Context (String h, int p, ByteBuffer r)
            {host=h; port=p; request=r;}
    Selector sel = null;
    boolean keepGoing = true;
    public NoWorkee()
        throws IOException
        sel = Selector.open();
    public void add(String host, int port)
        throws IOException
        int ops = SelectionKey.OP_CONNECT;
        // create non-blocking socket, and initiate connect operation
        SocketChannel sc = SocketChannel.open();
        sc.configureBlocking(false);
        sc.connect(new InetSocketAddress(InetAddress.getByName(host), port));
        SelectionKey sk;
        try
            sk = sc.register(sel, ops);
            System.out.println ( "sc.register looks good connected=" +
                sc.isConnected() + ", isConnectionPending=" +
                sc.isConnectionPending());
            sk.attach(new Context(host, port, ByteBuffer.wrap(GET_REQUEST.getBytes())));
        catch (IOException x)
            x.printStackTrace();
            sc.close();
    public void run()
        throws IOException
        keepGoing = true;
        System.out.println ( "Selecting " + sel.keys().size() + " SelectKeys");
        while (keepGoing)
            final long before = System.currentTimeMillis();
            final int numReady = sel.select();
            //final int numReady = sel.select(1000);
            final long after = System.currentTimeMillis();
            System.out.println ( "Blocked " + (after-before) + " ms, numReady=" + numReady);
            if (numReady > 0)
                Set readyKeys = sel.selectedKeys();
                System.out.println ( "Selected keys size " + readyKeys.size());
                for (Iterator it = readyKeys.iterator(); it.hasNext();)
                    SelectionKey sk = (SelectionKey)it.next();
                    SocketChannel sockChan = (SocketChannel)sk.channel();
                    Context ctx = (Context)sk.attachment();
                    System.out.println ( "Servicing host " + ctx.host + " port "
                                 ctx.port);
    System.out.println ( "1");
                    if (sk.isConnectable())
                        if (sockChan.finishConnect())
                            System.out.println ( "Finished connecting success "
    + sockChan);
                            int ops = SelectionKey.OP_READ | SelectionKey.OP_WRITE;
                            sk.interestOps (ops);
                        else
                            System.out.println ( "Could not finishConnect for "
                                sockChan);
                            sk.cancel();
                            sockChan.close();
    System.out.println ( "2");
                    if (sk.isAcceptable())
                        System.out.println ( "in sk.isAcceptable() block");
    System.out.println ( "3");
                    if (sk.isReadable())
                        System.out.println ( "in sk.isReadable() block");
                        byte rawBuff[] = new byte[32 * 1024];
                        ByteBuffer buff = ByteBuffer.wrap(rawBuff);
                        int numRead = -1;
                        while (0 < (numRead = sockChan.read(buff)))
                            System.out.println ( "numRead = " + numRead);
                            for (int i = 0; i < numRead; i++)
                                System.out.print((char)rawBuff);
    System.out.println ( "numRead = " + numRead);
    System.out.println ( "4");
    if (sk.isWritable())
    System.out.println ( "in sk.isReadable() block");
    int numWritten = -1;
    if (null != ctx.request)
    numWritten = sockChan.write(ctx.request);
    if (!ctx.request.hasRemaining())
    sk.interestOps(sk.interestOps() &
    ~SelectionKey.OP_WRITE);
    System.out.println ( "numWritten = " + numWritten);
    //else
    // service timeouts
    public static void main (String arg[])
    try
    NoWorkee bla = new NoWorkee();
    bla.add ("www.yahoo.com", 80);
    bla.run();
    catch (Exception e)
    e.printStackTrace();
    ------------------>8 cut here 8<-----------------------

    Just for the benefit of anyone who might be seeing the same problem, it looks like bug 4457776 accurately describes the problem that I was having above.
    I am downloading j2sdk-1_4_0-beta2-linux-i386-rpm.bin to see if that fixed it.
    Reference:
    http://developer.java.sun.com/developer/bugParade/bugs/4457776.html

  • FileChannel.transferTo() using non-blocking SocketChannel

    I'm looking to use FileChannel.transfer(From/To) for performing file transfers over a network. On the uploading side I find that even though I set the SocketChannel to non-blocking mode, the loop manages to send files as large as 30MB in only a single transferTo() invocation. What I'm hoping for is to have a series of partial writes so that I might generate progress notifications, which does occur on the downloading side with transferFrom(). I don't think a file that large should be transferred in one pass so I'm thinking that this is caused by either some internal buffer allocation issue or a goof-up on my part.
    Thanks in advance for any input and here's the uploading code:
    public void upload( String fileName ) {
    FileInputStream fileStrm = null;
    FileChannel fileChan = null;
    FileLock fileLock = null;
    SocketChannel sockChan = null;
    Selector selector = null;
    try {
    // Lock the source file.
    file = new File( fileName );
    fileStrm = new FileInputStream( file );
    fileChan = fileStrm.getChannel();
    fileLock = fileChan.lock( 0L, Long.MAX_VALUE, true );
    // Open a server socket bound to an arbitrary port.
    servChan = ServerSocketChannel.open();
    servChan.socket().bind( new InetSocketAddress( 0 ) );
    // Wait for a single connection and close the server socket.
    sockChan = servChan.accept();
    servChan.close();
    sockChan.configureBlocking( false );
    selector = Selector.open();
    SelectionKey selectorKey = sockChan.register( selector, SelectionKey.OP_WRITE );
    // Loop until transfer has completed.
    int fileSize = ( int ) file.length();
    int sizeLeft = fileSize;
    while ( sizeLeft > 0 ) {
    // Wait for data to read, then transfer it.
    if ( selector.select() == 1 && selectorKey.isWritable() ) {
    sizeLeft -= ( int ) fileChan.transferTo( fileSize - sizeLeft, sizeLeft, sockChan );
    // Generate a progress notification here such as:
    // monitor.bytesTransferred( fileSize - sizeLeft );
    catch ( IOException ex ) {
    ex.printStackTrace();
    finally {
    try {
    // Cleanup.
    if ( selector != null )
    selector.close();
    if ( sockChan != null )
    sockChan.close();
    if ( fileLock != null )
    fileLock.release();
    if ( fileChan != null )
    fileChan.close();
    if ( fileStrm != null )
    fileStrm.close();
    catch ( IOException ex ) {
    ex.printStackTrace();
    -Edwin

    Actually, the sending process appears way ahead of the receiving one, where the send seems to finish in a blink while the receive takes several seconds to complete. In other words, the transferTo() completes in one loop, while the transferFrom() performs many with delays in between. I'd guess all that data is sitting in some large outbound buffer at the sender, which would explain why it seems to finish too quickly. If I split the send into smaller chunks, the two sides run quite nearly at the same pace as expected.
    The receiver already sleeps by way of a select() against a non-blocking SocketChannel, so I'll try reducing the buffer sizes as you suggest.

  • HTTP Web Proxy using Non Blocking IO

    Resolved Thanks................

    client.register(selector, SelectionKey.OP_READ
    | SelectionKey.OP_WRITE);OP_READ only at this stage. OP_WRITE is always 'ready' unless the socket send buffer is full, so your selector will just spin. Don't register OP_WRITE until you have something to write.
    ByteBuffer bferClient = ByteBuffer.allocate(4096);You're doing this every time around the loop, and you don't even know whether the key is readable yet. Do it when you accept a connection, and save it as the key attachment for that channel.
    client.configureBlocking(false);It's already in non-blocking mode. Why are you doing this again?
    try {
    if ((bytesRead = client.read(bferClient)) != -1) {
    bferClient.flip();
    String msgFromClient = new String(bferClient.array());new String(bferClient.array(), 0, bferClient.limit()-1), but you're assuming you got a complete command here. You may not have. That's another reason why you need a ByteBuffer per channel.
    channel.connect(socketAddress);You should do that in non-blocking mode, register the channel for OP_CONNECT, and let the select loop take care of finishing the connection.
    channel.write(bferClient);The incoming command was CONNECT. You don't write that upstream.
    if (!"".equals(msgFromClient.trim())) {
    int bytesReadServer;
    byte[] reply = new byte[4096];
    try {
    ByteBuffer bufferNIO = ByteBuffer.allocateDirect(1024);
    while ((channel.read(bufferNIO)) != -1) {
    bufferNIO.flip();
    client.write(bufferNIO);
    bufferNIO.clear();
    }And you don't do any of this here. You register the new channel for OP_CONNECT, then when you get that do finishConnect() and then register it for OP_READ, and proceed around your select loop. You also need to associate this channel with the channel you read the CONNECT from. So you really need a key attachment object for the original channel that contains its byte buffer and the upstream channel; similarly the upstream channel needs a key attachment that contains its buffer and its downstream channel. The effect of doing all this stuff here instead of around the select loop is that you are never getting back to the select loop: you are handling this one client here, in blocking mode, until the connection is dropped. Completely wrong.
    } catch (IOException e) {Hang on. If bytesRead was -1 you must close the channel.
    e.printStackTrace();And if you get any IOException here you must also close the channel.
    if (channel != null) {
    try {
    channel.close();This is a really strange place to close this channel.
    When you get all that fixed up, post your code and I'll tell you how to handle OP_WRITE.

  • ORA-03118 two-task error while doing a non blocking OCI call

    Hi,
    I have an application that runs on Linux and uses OCI API (version 8.1.6).
    If I do the following in non blocking mode after polling about
    70 times I get the error:
    ORA-03118: two-task coroutine has invalid state
    do {
    call_cnt++;
    rtc = OCIStmtFetch(stmtptr->stmt, oracle_err, 1, OCI_FETCH_NEXT,
    OCI_DEFAULT);
    } while (rtc == OCI_STILL_EXECUTING);
    This doesn't happen all the time but it happens most often on big selects.
    Does anyone have any idea what is happening here?
    I have searched for related information but have come up dry. If anyone
    knows anything or maybe a better place to ask this question please tell me.
    Thanks,
    Barry
    null

    Ask your basis guys to increase the table space...
    check this thread...
    [Error : DBIF_RSQL_SQL_ERROR;
    --- Thanks...

  • Non-blocking file behaviour for Reader

    Hi!
    It will be really nice if Reader will not block files for writing. Assume someone is using TeX to create PDF and he need to
    a) examine the results;
    b) edit the source.
    It becomes a nightmare with Reader. Compile TeX, open Reader, examine results, close Reader. And then from the beginning.
    Auto reloading of a PDF file is also a nice feature!
    So far I can see only one solution: one should use another viewer to get non-blocking behaviour.
    Thanks!

    OK, let us see. I use Windows XP Professional SP3, Reader version is 9.3.0. I made a simple test: openned a file in Reader, then openned this file in my favourite text editor and tried to change "%PDF-1.4" to "%PDF-1.3" and save. I received a "File sharing violation error". I can also try to do it in Ubuntu.
    As for the open source viewers. That is what I am currently doing: I use additional viewer to view the files I create and I use Adobe Reader to view all other files. One can leave with such solution, but it is not the best.

  • Using non-blocking NIO, need Main Thread wait?

    I'm trying to utilize the New IO libraries to create a simple url check application. The application just tests return codes to make sure the list of urls I have are still valid.
    I'm using the NIO libraries because I had problems with the URLConnection object hanging when I ran into a url where the server never replied. It just sat there waiting for a reply.
    Now I have a new problem, the connection to the web server is now in a new thread and I need to wait for the connection to finish before using it. I can't figure out how to make the main app wait for the connection. All of the documentation I find for the Wait() method refers to threads and I can't find how to refer to the main application thread.
    Any suggestions?
    Josh

    Ok, this is were I have some gaps in my Java knowledge. How do I wait for OP_CONNECT to fire. Is it like setting up a ActionListener but for a non-visual object?
    Also what do you mean when you refer to deregistering it?
    You don't need to explain everything. I would be happy if I was just pointed at the appropriate pages and I'll do the leg work.
    Josh
    If you're using NIO the connection can be handled in
    the same thread as the I/O. Just wait for OP_CONNECT
    to fire, deregister it, and away you go.

  • How to use the camera connection kit for iPad 3rd generation?

    Hi I just bought a new camera connection kit for my iPad 3rd generation. Does anyone have any experience or knows how to use it? I tried to connect a USB to it and nothing happened. Please help...

    This is how you use it.

  • Read data using 2 diff connection pool for same DB folder in physical layer

    Hi All,
    i am using two connection pool which have different dsn connection information (both are directed to different database name or database server)..
    so if i view the data of any table, a prompt will come asking for the connection pool, so how do i automize it....?
    how do i set the different connection pool for different tables?
    please let me know if u need further informtaion to understand my problem..
    thnx...

    thnx Stijn..
    yupe that i know...
    actually i have total of around 300 tables in physical layer (in both the schemas..) , around 12 fact and 100 dimension tables in bmm and same in the presentation layer...
    so i think u can guess how many joins and other stuff, i have made in my bmm layer..
    if now i will start modifying all this it will take lot of time...
    i am just wondering that there is no alternative for this...
    as when i check my data from the physical layer then a prompt ask for the connection pool (i have already made two connection pool..) so there could be some alternative way to automize the default connection pool setting for the tables/schemas folders in case if more than one connection pool exits under the same database in the physical layer...
    isn't it?
    thnx again..

  • Is there an APK android app downloader for Firefox? Need to download via PC then copy to a non-internet connected tablet for installation

    I have two Android tablets that are not connected to the internet (long story). I'd like to download Android Apps via my PC and copy them to my Android tablets. I do not want to use the Chrome APK extension for a variety of reasons. The apps I need are free, but without an internet connection, I can't obtain them. They are not available for direct download from the developer sites.

    Read the question again FredMcD, he was asking for ways to download .apk files on computer to then install them on Android tablets.

  • File transfer using non-blocking sockets - data mysteriously  vanish

    Hello,
    I need to pass some big amount of data using sockets. I my appliaction I have noticed that sometimes I didn't get all bytes. To check it out I wrote simple client + server to figure out what is happening. So:
    - I have a sender and receiver application
    - I'm trying to transfer 5MB text file.
    - On receiver side, output file is never larget than 3MB
    - If I put some timeout on sender side (1ms timeout between write operations) everything works fine.
    Could someone tell me what I do wrong? Why data disappears and when? The same file transfered using old sockets goes always fine...
    Thanks in advance!
    Here is complete source for receiver and sender:
    RECEIVER:
    import java.io.FileOutputStream;
    import java.net.InetSocketAddress;
    import java.nio.ByteBuffer;
    import java.nio.channels.SelectionKey;
    import java.nio.channels.Selector;
    import java.nio.channels.ServerSocketChannel;
    import java.nio.channels.SocketChannel;
    import java.util.Iterator;
    public class ReceiverA {
          * @param args
         public static void main(String[] args) {
              String outputFile = "c:\\outputA.txt", host = "127.0.0.1";          
              int port = 8001, bufferSize = 10240;
              try {
                   ByteBuffer buffer = ByteBuffer.allocate(bufferSize);
                   Selector selector = Selector.open();
                   ServerSocketChannel server = ServerSocketChannel.open();
                   server.configureBlocking(false);
                   server.socket().bind(new InetSocketAddress(host, port));
                   server.register(selector, SelectionKey.OP_ACCEPT);
                   System.out.println("Server started");
                   while(true)
                        selector.select();
                        Iterator<SelectionKey> iterator = selector.selectedKeys().iterator();
                        while (iterator.hasNext()) {
                             SelectionKey key = (SelectionKey) iterator.next();
                             iterator.remove();
                             if (key.isAcceptable()) {                              
                                  SocketChannel client = server.accept();
                                  client.configureBlocking(false);
                                  client.register(selector, SelectionKey.OP_READ);                              
                                  continue;
                             SocketChannel channel = (SocketChannel) key.channel();
                             int counter = 1;
                             if ( key.isReadable() ) {
                                  FileOutputStream os = new FileOutputStream(outputFile);
                                  int res;
                                  do
                                       buffer.clear();
                                       res = channel.read(buffer);
                                       counter += res;
                                       System.out.println(res);
                                       buffer.flip();
                                       os.write(buffer.array(), 0, buffer.limit());
                                  while( res >= 0 );          
                                  channel.close();
                                  os.close();          
                                  System.out.println("Receiver: " + counter);
                                  return;
              } catch (Exception e) {
                   e.printStackTrace();
    }SENDER:
    import java.io.FileInputStream;
    import java.io.IOException;
    import java.net.InetSocketAddress;
    import java.nio.ByteBuffer;
    import java.nio.channels.SelectionKey;
    import java.nio.channels.Selector;
    import java.nio.channels.SocketChannel;
    import java.util.Iterator;
    public class SenderA {
         public static void main(String[] args) {
              String inputFile = "c:\\inputA.txt" , host = "127.0.0.1";          
              int port = 8001, bufferSize = 10240;
              try {
                   ByteBuffer buffer = ByteBuffer.allocate(bufferSize);
                   byte[] byteArr = new byte[buffer.capacity()];
                   Selector selector = Selector.open();
                   SocketChannel connectionClient = SocketChannel.open();     
                   connectionClient.configureBlocking(false);
                   connectionClient.connect(new InetSocketAddress(host, port));
                   connectionClient.register(selector, SelectionKey.OP_CONNECT);
                   while(true) {
                        selector.select();
                        Iterator<SelectionKey> iterator = selector.selectedKeys()
                                  .iterator();
                        while (iterator.hasNext()) {
                             SelectionKey key = (SelectionKey) iterator.next();
                             iterator.remove();
                             SocketChannel client = (SocketChannel) key.channel();
                             if (key.isConnectable()) {
                                  if (client.isConnectionPending()) {
                                       System.out.println("Trying to finish connection");
                                       try {
                                            client.finishConnect();
                                       } catch (IOException e) {
                                            e.printStackTrace();
                                  client.register(selector, SelectionKey.OP_WRITE);
                                  continue;
                             if(key.isWritable()) {
                                  FileInputStream is = new FileInputStream(inputFile);
                                  int res;
                                  int counter = 0;
                                  do
                                       buffer.clear();
                                       res = is.read(byteArr, 0, byteArr.length);                                   
                                       System.out.println(res);
                                       if ( res == -1 ) break;
                                       counter += res;
                                       buffer.put(byteArr, 0, Math.min(res, buffer.limit()));
                                       buffer.flip();
                                       client.write(buffer);
                                        * When I remove comment file transfer goes OK!
                                       //Thread.sleep(1);
                                  while( res != -1 );          
                                  client.close();
                                  is.close();          
                                  System.out.println("Receiver: " + counter);
                                  return;
              catch(Exception e) {
                   e.printStackTrace();
    }

    There are at least two problems here.
    A. In the receiver you should test for -1 from the read() immediately, rather than continue with the loop and try to write -1 bytes to the file.
    B. In the sender you are ignoring the return value of client.write(), which can be anything from 0 to the buffer length. If you get 0 you should wait for another OP_WRITE to trigger; if you get a 'short write' you need to retry it until you've got nothing left to write from the current buffer, before you read any more data. This is where the data is vanishing.

Maybe you are looking for

  • Acrobat 9 ad in not working in excel.

    The ad in is there, when I hover mouse over option to create PDF I get additional options, but when I go to choose the option I want, it fades away.  I can create PDF's within Acrobat 9 program, but really need to have the ad in work in excel.

  • Issue in while connecting Source system

    Hi All, I mistakenly Ran the function module RSAP_BIW_DISCONNECT in BIW, I suppose to run this FM in Source system side, We observed that Source system in RSA1 (BI) has been deleted), and also one record from the table RSBASIDOC (which is from source

  • IOS7 + Mail

    Have just upgraded to IOS7, however when I open up mail, I do not have an inbox or search box showing.  All previous emails have disappeared although I can view deleted emails. I have a box which is called 'unread' into which a email arrived.  howeve

  • How to block "Personal Hotspot (Tethering)"?

    Hello, I want to block or deactivate the "personal hotspot" function on iPad or iPhone. We want to disallow the use of this function for all of our users. I checked the "Apple Configurator" and also our MDM solution. It is not possible to block. Also

  • Clone of auxillary database using rman with the source database unavailable

    Hi, Is it possible to clone a database with just the source database's backup pieces. The source database is currently unavailable. The source database backup was taken through rman - nocatalog mode. We have been provided the backup pieces. Any clues