Socket channel read return

client server java nonblocking SocketChannel
at the server do writes using this:
socketChannel.write(byteBuffer);
At the client end do a read
socketChannel.read(inBuffer);
When does the client read method return ?. Assume inBuffer is empty and is bigger than byteBuffer. Does it wait until it gets all of a single write or if there is an internet delay does it return with only part of the write bytes?
Can read return with only some of the bytes sent in a single write ?
The point am getting at is can inBuffer after a read have 2 partial write packets, or several write packets with perhaps partial packets at the start and end ?
thanks
p butler

With TCP/IP read() can return any number of bytes from 1 to the size of the buffer (also 0 bytes if you have a non-blocking socket). The sending operating system, the receiving operating system, and all routers/firewalls/etc in between can break up and/or combine writes any way they want to. TCP is a stream protocol, not a packet protocol; "packet" or write() boundaries are not preserved.
There are a couple of common ways to send "packets":
A line based protocol. Each "packet" is a single line of text. If the actual payload data can contain \r or \n characters, those need to be escaped with a suitable escape character. Other packet terminators can be used also. e.g. "\n.\n" (= a period on a line of its own.)
Length+data. Before sending a "packet", send an e.g. 4-byte value that tells how long the packet is. In the receiver, read until you have that many bytes. Note that even the 4-byte length header can be split up so that you may need to do four read() calls to get them all! DataInputStream has a readFully() method, or you can write your own static utility; see reply 5 here: http://forum.java.sun.com/thread.jspa?threadID=677542

Similar Messages

  • Reading lots of bytes from a socket channel

    Hello,
    I have a client/server architecture.
    My server writes() to a socketChannel the contents large byteBuffer.
    On my client, I read() the socketChannel in to a byteBuffer. However, the data I wrote to the socketChannel is so large that it doesn't all arrive in one read(). I get a byteBuffer, but it isn't complete.
    Is there any way to know that there is more data waiting on the socketChannel, as it were? Or do I need to handle this myself by keeping track of the number of incoming bytes?
    Cheers!

    I was wondering whether Java had any kind of internal way of saying "I've not yet finished writing what I was told to write....there's more data to come".Socket.Channel.write() returns a byte count. If it's less that you expect, the write was incomplete.
    I suspect the answer is "no"No, the answer is 'yes', unless you are ignoring the return value.
    The canonical way to write a buffer is this:
    while (buffer.position() > 0)
      try
        buffer.flip();
        int rc = channel.write(buffer);
        if (rc == 0)
            // Here you must register the channel for OP_WRITE
            // and wait for it to trigger before trying again, not shown.
            key.interestOps(SelectionKey.OP_WRITE);
            break;
      finally
        buffer.compact();
    if (buffer.position() == 0)
      // The entire buffer has been written.
      // At this point you deregister the channel for OP_WRITE,
      key.interestOps(0);
      // or more probably re-register for OP_READ.
      key.interestOps(SelectionKey.OP_READ);
    }

  • Using a selector to detect closed socket channel.

    Basically our app uses one thread to perform a select on multiple socket channels. When a socket is closed (either remotely or locally) the server app needs to unregister the client (so we need to detect closed channels). We've been using blocking IO previously (no dramas), but now we're dealing with many connections/clients we need to rework it as we're getting excessive amounts of threads. Anyway, that's just background.
    Here's the problem we're getting, I have boiled it down to the following.
    SocketChannel channel = SocketChannel.open();
    channel.connect(socketAddress); // for the test this is localhost.
    // this make sure socket is open, remote end just echos, waits 3 seconds and closes the socket.
    channel.write(ByteBuffer.wrap("testLocalSocketClose\n".getBytes()));
    channel.configureBlocking(false);
    Selector selector = Selector.open();
    LOG.fine("registering channel");
    channel.register(selector, SelectionKey.OP_READ, channel);
    LOG.fine("closing channel");
    channel.close();
    LOG.fine("waiting...");
    int i = selector.select();
    // this never happens (or it does very rarely)
    LOG.fine("selector woke with " + i + " selected");I would have expected the selector to return the selection key of the dead channel. Given that it doesn't and this scenario is possible (channel closing just after a read operation but before another select is called - in separate threads obviously). How can we reliably detect/be informed that the channel has been closed?
    (I saw somewhere someone mention adding the OP_WRITE to the key, I have tried this as well and it makes no difference).
    Many Thanks.
    Bob.

    May I suggest you look at your application and reassess; either it's wrong or it's your understanding of what our issue is.
    Please try the simple test below.
    WSADATA ws;
    WSAStartup(0x0101, &ws);
    SOCKET sock = socket(PF_INET, SOCK_STREAM, 0);
    struct sockaddr_in server;
    server.sin_family = AF_INET;
    server.sin_addr.s_addr = htonl(INADDR_ANY);
    server.sin_port = htons(9000);
    cout << "binding" << endl;
    bind(sock, (struct sockaddr *)&server, sizeof(server));
    cout << "listening" << endl;
    listen(sock, SOMAXCONN);
    struct sockaddr_in client;
    int client_size = sizeof(client);
    memset(&client, 0, client_size);
    cout << "accepting" << endl;
    SOCKET clientSock = accept(sock, (struct sockaddr*)&client, &client_size);
    // shutdown socket.
    cout << "shutting down client socket" << endl;
    shutdown(clientSock, SD_BOTH);
    // setup select
    FD_SET fd;
    TIMEVAL tv;
    FD_ZERO(&fd);
    tv.tv_sec  = static_cast<int>(6000);
    tv.tv_usec = 0;
    FD_SET(clientSock, &fd);
    cout << "selecting" << endl;
    int rc = select(0, &fd, NULL, NULL, &tv);     
    cout << rc << ", " << FD_ISSET(clientSock, &fd) << endl;
    char msg[500];
    if (FD_ISSET(clientSock, &fd)) {
         cout << recv(clientSock, msg, 500, 0) << endl;
         cout << WSAGetLastError() << endl;
    cout << "closing" << endl;
    closesocket(clientSock);Telnet to port 9000, you get the following output immediately:
    binding
    listening
    accepting
    shutting down client socket
    selecting
    1, 1
    -1
    10058
    closing
    The solution I posted previously re calling shutdownInput/Output in Java isn't correct however, I left OP_WRITE on by mistake, which always returns ready, my fault.  Apologies.
    Whatever the behaviour, it will be the same for Selector.select() as it is for select().
    Clearly not.
    Edited by: Bawb on 29-Jul-2011 07:01, I had left OP_WRITE on which was returning ready each time, when I realised and took it out I removed the shutdown code which made me think I hadn't sorted this. Apologies again.
    Still reckon an RFE for OP_SHUTDOWN should be added to Java.
    Thanks.

  • Reg. Socket Channel Write Method

    Hi,
    We have the following method to write into the socket channel.
         private void write(SelectionKey key)
              SocketChannel channel = (SocketChannel) key.channel();
              try
                   channel.write(writeBuffer);
                   key.interestOps(SelectionKey.OP_READ);
              catch (IOException ioEx)
                   LogUtility.log(Level.SEVERE, ioEx);
    My doubt is, in case of any network related issues and network goes down, how to trap those exception. In those cases, i need to re-establish the connection again to the remote host.
    I tried to check, whether channel.isConnected b4 writing, but the doc says this will return false if the connect operation is never fired.
    It will be helpful for me, if some one gimme an idea to proceed on this.
    Best Regards,
    K.Sathishkumar

    If you get any IOException or SocketException other than a SocketTimeoutException when doing I/O to a socket or SocketChannel you must close the socket/channel. It is of no further use. What else you do depends on the application - log it, maybe try to re-establish the connection if you are a client, forget about it if you are a server.
    BTW:
    We have the following method to write into the socket channel.
    private void write(SelectionKey key)
    SocketChannel channel = (SocketChannel) key.channel();
    try
    channel.write(writeBuffer);
    key.interestOps(SelectionKey.OP_READ);This is not valid. You shouldn't throw away the result of the write and just assume the data got written as you are doing here. You should do something like this:
    try
      // assuming the buffer is already flipped
      int count;
      while (writeBuffer.hasRemaining() && (count = channel.write(writeBuffer)) > 0)
      if (count == 0)
        key.interestOps(SelectionKey.OP_WRITE);
      else
        key.interestOps(SelectionKey.OP_READ);
    catch (IOException ioEx)
      LogUtility.log(Level.SEVERE, ioEx);
      try
        channel.close();
      catch (IOException ioEx2)
        LogUtility.log(Level.SEVERE, ioEx2);
    // ...}

  • UDPWrite in a loop. "A Windows Sockets function call returned an unexpected error."

    Hello together,
    i use UDP Support Library in NI CVI 9.0. When i wait for receiving a packet at the pc to send then a packet from the pc, the functions UDPRead and UDPWrite work fine. If i want to test the maximum throughput, i put the UDPWrite in a loop, but then an error occurs. It is "kUDP_UnexpectedWinsockError"
    Error Popup:
    "NON-FATAL RUN-TIME ERROR:   "main.c", line 53, col 22, thread id
    0x00000C18:   Library function error (return value == -6822
    [0xffffe55a]). A Windows Sockets function call returned an unexpected
    error."
    Line 53:
    status = UDPWrite (channel, 60100, "192.168.1.10", pOutputBuffer, 1458);
    the whole loop:
    while(1)
    status = UDPWrite (channel, 60100, "192.168.1.10", pOutputBuffer, 1458);
    counter++;
    if(counter>50)
    break;
    else{;}
    The error occurs after 3-16 packets have been sent. If i step through the programm, no error occurs. So i guess its because the UDPWrite command is invoked too fast. pOutputBuffer has static data. I could use a delay in the loop, but then i dont know how to configure for maximal throughput.
    Any ideas how to avoid this error?
    Regards Florian

    Hello and thank you for your answer. Sorry that i reply a month later.
    I dont know what you mean by "let 'er rip approach". Do you mean something like:
    status = UDPWrite (channel, 60100, "192.168.1.10", pOutputBuffer, 1458);
    if(status==0)
     counter++;
    else
      Delay(0.00005);
    I did not yet try to put the packet number in the payload, but there is just a 30 cm crossover cable between the two devices, no switch, no router. So the sequence should not be interruptet. And even if they arrive in chaos, i dont mind.
    I have contacted the NI support 2 weeks ago, but no response yet.
    I did some tests with a delay between the execution of UDPWrite(). The code:
    float time = 0.0;
     for(i = 1; i < 1000; i++)
      status = UDPWrite (channel, 60100, "192.168.1.10", pOutputBuffer, 1458);
      time = 1.0 / i;
      Delay(time);
    The results:
    For i between 1 and 1000: no error, the speed of the last ten packets was about 6.5 MBit/s
    For i between 1000 and 2000: error occured at i = 1585 (variable time in Delay was 0.0006313), the speed of the last ten packets was about 8 MBit/s
    Then i put some constant values in Delay and ran 100 UDPWrite iterations:
    Delay(0.0006): 7.48 MBit/s
    Delay(0.0001): 10.7 MBit/s
    Delay(0.00001): error occured at i=31, speed of 31 packets was 12.0 MBit/s
    Delay(0.00008): 100 of 100 packets, speed 10.9 MBit/s
    Delay(0.00005): error at i=41, speed of 41 packets 11.1 MBit/s

  • Block again after InputStream.read() return -1

    Hello,
    I've got the following problem: I call read() on my InputStream object until the function return -1. The read() call is done in a loop. After that i start processing the received data. The socket is not closed and i want to start a blocking read() call again. But this doesn't work. Instead the read() return -1 again and again..... This make sense to me because there are actually no data, but i expected that read() is blocking again.
    Does anyone know this problem?
    By the way: Can i change my screen name. I typed in some stupid stuff as I think i could change is later.
    Thanks
    Christian

    read() returning -1 means that the other end has closed the connection. All you can do is close yours. There will never be any more data so there is nothing for it to block for.

  • Is it possible to execute Single Channel read of AI channel too quickly?

    When executing single channel read of volts on 16XE50 in VB6 it seems to return an errornous result if too fast. Increase the time between reads and the result is correct. I need to scan single channel quickly for short period to check a trip point and stop some motion. Any clues?

    Check the Zout of your signal source. Any stored charge on the amp inputs needs to be bled off trough your source. If it is higher thatn 1kohm, the settling time of the amp is higher than that guaranteed for maximum accuracy.
    NI recommends 10kohm or less, with 1kohm for guaranteed accuracy. You may have to buffer the output of your signal.

  • Socket stream read() method blocks

    Hi,
    client connects to our server socket.
    our thread blocks for getting the input data from the client, but the client is closed with out sending any data.
    so our thread is blocked for the input data for ever.
    how could our application will know that the client socket is closed.
    once we got some data from the client , after that client is closed then we can know that the client is closed because read() method will return -1 .
    Thanks ,
    S P K S.

    yes you are right when the client sent some data then after some time connection got closed , then our read() will return -1It doesn't matter whether the client has sent data or not. If the client closes the connection properly your read will return -1.
    but here my problem is just client is connected , he didn't send a bit of data , connection got closed ,in that case read method is still waiting for the input it is not returning any thing and not throwing any exception.If the connection is dropped abortively a read can block forever. Your defence against this is to use a read timeout of say 60 seconds. or whatever is appropriate for your application. See Socket.setSoTimeout().

  • CAN Read returning default samples

    I am using the Channel API.  I am initializing and starting a task for reading one channel at 50hz.  Then in another VI, I read the channel with 'single channel - multiple samples' read VI.  I read 10 samples.  What happens is that I get 10 samples of data, but the first two samples are defaults for the channel.  The remaining 8 samples are real data.
    Is it possible that when the sample is taken every 50hz, if there is no frame being broadcast at that point, that the read returns the default value?  If so, how would I get the last 10 non-default samples?  The channel data that I am reading has a broadcast rate of 50hz.

    Hi,
    Thats because you have declared '/usr/sap/KIDZ/TST/Kidz_Ex/README.TXT' for a variable with 20 characters
    data: dsn(20)  type c value '/usr/sap/KIDZ/TST/Kidz_Ex/README.TXT'.
    Here the variable dsn will hold the path only upto 20 characters, Which will be a invalid path and thats the reason why its not working.
    Declare it with a higher char length it should work fine.
    data: dsn(70)  type c value '/usr/sap/KIDZ/TST/Kidz_Ex/README.TXT'.
    Regards,
    Vik

  • Simple Channel Read and File I/O Problem

    Hello
         I am having a simple problem with reading in two channels from a usb-6259.  I have 2 channels, reading in voltages, and I am wanting to read them in at 400K Hz.  I have used the DAQ assistant and the Write To Measurement File VI.  It is just a direct connection between the two.  I have the DAQ assist set up for taking in N Samples, which is set to 8M because I want to take in 20 seconds worth of data at 400K Hz.  Now the problem lies with the fact that I am getting a Out of Memory error.  This pretty much confuses me because the file that I will get is 220MB (I know this because I put a wait and got none continuous data for a total of 20 seconds worth of data at 400K Hz), and I have 2 GB of RAM, in whic i usually have 1.3GB free when I start the simulation.  So, now on to my actual question.  How is this system running out of memory?  How else can I program this to make this work?  Any feedback on this would be great.  Thank you.
    Michael B
    Labview 8.5

    Hello Michael B,
    The DAQ assistant creates a lot of over head and this may be the reason why you are running out of memory. If you keep the Task Manager open while you are running the task, you'll be able to see that the memory keeps being used up by the data acquisition process. I would suggest not using the DAQ assistant and to use the lower level DAQmx VIs.
    A good place to start would be Help -> Find Examples. Within Find Examples select Hardware Input and Output -> DAQmx -> Analog Measurements -> Voltage -> Acq&Graph Voltage Int Clk.vi. Go to the Block Diagram of the VI and change the "time out" to a much larger value. You can select two channels at the same time by using a comma (eg: Dev2/ai0, Dev2/ai1). Hope this helps.

  • Subprocess 33 was not successful. Master cannot read return value from S 33

    Hi All,
    We are on BI 7.0 SP 19.
    We have submitted a planning sequence in the background with automatic packaging.
    The planning sequence has two steps:
    Step 1. Z_PLNG_FUNCTION1
    Step 2. Z_PLNG_FUNCTION2
    As per automatic packaging, the system chose 0ACCOUNT for packaging.
    When submitted, each step has been submitted to 30 packages as 30 subprocesses.
    For Step 1, the log shows that All subprocesses  executed.
    For Step 2, the log shows that the subprocess 33 and 58 failed, which means subprocess #3, and # 28 for the step 2 as the subprocess is numbered in the log in combination with step 1.
    The messages in the log for the failed subprocesses are as follows:
    @5C\QError@     Subprocess 33 was not successful
    @5C\QError@     Master cannot read return value from subprocess 33
    @5C\QError@     Subprocess 58 was not successful
    @5C\QError@     Master cannot read return value from subprocess 58
    Our question is on how to find the exact cause of the subprocess failure.
    I tried to look for the details on the error messages, they have been not helpful.
    What is meant by 'Master cannot read return value from subprocess' and how to get the exact cause of the failure?
    Thanks in advance,
    Best Regards,
    - Shashi

    Shashi,
    implement the following notes and check again:1368659, 1525723, 1532061.
    Regards,
    Marc
    SAP Techology RIG

  • RE: (forte-users) Reading return value from Javaprogram

    when using the RunCommand method you can specify the an error file:
    task.part.os.RunCommand(command = l_tdCommandLine,
    isSynchronous = TRUE,
    inputFile = Nil,
    outputFile = Nil,
    errorFile = l_ErrorFile.GetLocalName(TRUE));
    BEGIN
    l_ErrorFile.Open(SP_AM_READ);
    EXCEPTION
    WHEN Ex: FileResourceException DO
    l_ErrorFile = NIL;
    task.ErrorMgr.Clear();
    END;
    IF l_ErrorFile <> NIL THEN
    l_tdFileContents : TextData = New();
    l_ErrorFile.ReadText(l_tdFileContents);
    l_ErrorFile.Close();
    END IF;
    Have you java program output the return value to the standard IO. This way
    you will have an error file that you can read from Forte.
    ka
    -----Original Message-----
    From: Anthony D [mailto:saigonxyahoo.com]
    Sent: Tuesday, September 12, 2000 7:49 AM
    To: forte-userslists.xpedior.com
    Subject: (forte-users) Reading return value from Java program
    Hi,
    Does anyone know whether Forte application can
    read a return value from a Java program?
    I'm using the RunCmd method to invoke the Java
    program. I'd like to read the return value from the
    Java program. How do I go about doing it?
    Any suggestion will be appriciated.
    Thanks
    AD
    http://mail.yahoo.com/
    For the archives, go to: http://lists.xpedior.com/forte-users and use
    the login: forte and the password: archive. To unsubscribe, send in a new
    email the word: 'Unsubscribe' to: forte-users-requestlists.xpedior.com

    when using the RunCommand method you can specify the an error file:
    task.part.os.RunCommand(command = l_tdCommandLine,
    isSynchronous = TRUE,
    inputFile = Nil,
    outputFile = Nil,
    errorFile = l_ErrorFile.GetLocalName(TRUE));
    BEGIN
    l_ErrorFile.Open(SP_AM_READ);
    EXCEPTION
    WHEN Ex: FileResourceException DO
    l_ErrorFile = NIL;
    task.ErrorMgr.Clear();
    END;
    IF l_ErrorFile <> NIL THEN
    l_tdFileContents : TextData = New();
    l_ErrorFile.ReadText(l_tdFileContents);
    l_ErrorFile.Close();
    END IF;
    Have you java program output the return value to the standard IO. This way
    you will have an error file that you can read from Forte.
    ka
    -----Original Message-----
    From: Anthony D [mailto:saigonxyahoo.com]
    Sent: Tuesday, September 12, 2000 7:49 AM
    To: forte-userslists.xpedior.com
    Subject: (forte-users) Reading return value from Java program
    Hi,
    Does anyone know whether Forte application can
    read a return value from a Java program?
    I'm using the RunCmd method to invoke the Java
    program. I'd like to read the return value from the
    Java program. How do I go about doing it?
    Any suggestion will be appriciated.
    Thanks
    AD
    http://mail.yahoo.com/
    For the archives, go to: http://lists.xpedior.com/forte-users and use
    the login: forte and the password: archive. To unsubscribe, send in a new
    email the word: 'Unsubscribe' to: forte-users-requestlists.xpedior.com

  • Socket Channel Connection - Continuous read

    Hi all,
    I am new to socket programming. This is where I am stuck...I need to read from a channel 'continuously', i.e messages are continuous published and I need to keep on reading it. Below is my code for review....I am just getting the 1st line of the message. please suggest..Thanks in advance
    import java.io.IOException;
    import java.net.InetAddress;
    import java.net.InetSocketAddress;
    import java.nio.ByteBuffer;
    import java.nio.CharBuffer;
    import java.nio.channels.ReadableByteChannel;
    import java.nio.channels.SelectionKey;
    import java.nio.channels.Selector;
    import java.nio.channels.SocketChannel;
    import java.nio.charset.Charset;
    import java.nio.charset.CharsetDecoder;
    import java.util.Iterator;
    import java.util.Set;
    public class TestConnection {
         private static Charset charset = Charset.forName("ISO-8859-1");
         private static CharsetDecoder decoder = charset.newDecoder();
         public static void main(String[] args) throws IOException {
              SocketChannel sc = null;
              String desthost = "172.19.67.33";
              int port = 5002;
              InetSocketAddress isa = new InetSocketAddress(InetAddress.getByName(desthost), port);
              try {
                   sc = SocketChannel.open();
                   sc.connect(isa);
                   System.out.println(" Message--> " + readFromChannel(sc, 4096));
              } catch (Exception e) {
                   e.printStackTrace();
              } finally {
                   if (sc != null)
                        sc.close();
         public static String readFromChannel(SocketChannel sChannel, final int size) throws IOException {
              int numBytes = 0;
              boolean hasRead = false;
              ByteBuffer inBuffer = ByteBuffer.allocateDirect(size);
              CharBuffer charBuffer = CharBuffer.allocate(size + 100);
              StringBuffer dataRead = new StringBuffer();
              Selector selector = Selector.open();
              System.out.println(" Is Connected--> " + sChannel.isConnected());
              System.out.println(" sChannel.isBlocking()--> " + sChannel.isBlocking());
              sChannel.configureBlocking(false);
              System.out.println(" sChannel.isBlocking()--> " + sChannel.isBlocking());
              sChannel.register(selector, SelectionKey.OP_READ);
              try {
                   while (selector.select(20000) > 0) {
                        Set readyKeys = selector.selectedKeys();
                        Iterator readyItor = readyKeys.iterator();
                        while (readyItor.hasNext()) {
                             SelectionKey key = (SelectionKey) readyItor.next();
                             readyItor.remove();
                             ReadableByteChannel keyChannel = (SocketChannel) key.channel();
                             if (key.isReadable()) {
                                  for (int i = 0;; i++) {
                                       int count = 0;
                                       if ((count = keyChannel.read(inBuffer)) < 0) // EOF
                                            keyChannel.close();
                                            throw new IOException("Socket lost connection during read operation");
                                       numBytes += count;
                                       if (!inBuffer.hasRemaining()) {
                                            hasRead = true;
                                            System.out.println("has read");
                                            System.out.println("SUCCESSFUL, length of data read:" + numBytes);
                                            inBuffer.flip();
                                            decoder.decode(inBuffer, charBuffer, false);
                                            charBuffer.flip();
                                            selector.close();
                                            return dataRead.append(charBuffer).toString();
                                       if (i >= 2) {
                                            break;
                   if (false == hasRead) {
                        System.err.println("has _NOT_ read");
                        System.err.println("length of data read: " + numBytes);
                        System.err.println("length of data read: " + numBytes);
                        if (numBytes > 0) {
                             inBuffer.flip();
                             decoder.decode(inBuffer, charBuffer, false);
                             charBuffer.flip();
                             System.err.println("ERROR, data read: " + dataRead.append(charBuffer).toString());
                        throw new IOException("Socket read operation timed out");
                   } else {
                        throw new IOException("Invalid Read Socket state");
              } finally {
                   selector.close();
    }

    The output is -->
    Is Connected--> true
    sChannel.isBlocking()--> true
    sChannel.isBlocking()--> false
    has read
    SUCCESSFUL, length of data read:4096
    Message--> 000c100000300000007f100700302E12008071104060400 Lane Communication Is OK 004d100500300302E0100000027000000000000000000000000000010845800000000000000000000000c100000302E01007f100700303E12008071104140200 Lane Communication Is OK 004d100500300303E0402350427000000000000000000000000000119107300000008500000000000000c100000303E00007f100700304E12008070704085600 Lane Communication Is OK 004d100500300304E0201521427000000000000000000000000000081090700000003640000000000000c100000304E00007f100700305X12008071104111600 Lane Communication Is OK 004d100500300305X0801411215000000000000000000000000000048892600000000810000000001000c100000305X00007f100700306X12008071104102600 Lane Communication Is OK 004d100500300306X0800660815000000000000000000000000000046838800000000760000000000000c100000306X00007f100700307X12008063003542200 Lane Communication Is OK 004d100500300307X1000445315000000000000000000000000000125509000000017220000000127000c100000307X000104100300300307X200807111727309311015004453030200000000000000000000000000000527000001020102000000001154210344501304E2008071116072500EZPASS TAG# 022 - 04522780 STATUS = VALID TYPE = INTERIOR FPT Program Status = Success 00012550910000001723000000012820104100300300305X200807111727325610815014112010200000000000000000000000000000000010201020102000000005146360015500121E2008071117010800MANUAL CASH IN EXIT MANUAL 00004889270000000082000000000100104100300300307X200807111727353911015004453030200000000000000000000000000000072000001020102000000001154220344700103E2008071117070600EZPASS TAG# 008 - 03623801 STATUS = VALID TYPE = INTERIOR FPT Program Status = Success 00012550920000001724000000012800104100300300307X200807111727379411015004453030200000000000000000000000000000072000001020102000000001154230344900401E2008071117181300EZPASS TAG# 006 - 00468916 STATUS = VALID TYPE = INTERIOR FPT Program Status = Success 00012550930000001725000000012800104100300300306X200807111727399610815006608010200000000000000000000000000000000010201020102000000000075910013300613E2008071117032500MANUAL
    The out actually gives multiple line...but what should be the approach to read line by line continuously and keep parsing them......
    kind regards

  • Muti-channel read/write through FP data socket posible?

    Hello,
    I'm trying to talk to cFP-1808 module from desktop PC real-time host over Ethernet. I did not find any Fieldpoint driver for desktop RT so I'm forced to use data sockets to communicate with cFP-1808. It seems that one can only read or write to one FP data channel per socket. With typical latency of tens of milliseconds per such read/write and couple of hundreds channels present, I'm looking at SECONDS per cycle time, which is really slow.
    Is there any workaround for this problem?

    You can also read and write to channels in LabVIEW.  First you have to configure your 1808 in MAX and save the IAK file.  You then load the IAK file in LabVIEW by selecting browse in the FieldPoint IO Point In (constant or control).
    In the FieldPoint Device Selection Dialog Windows select the View Configurations Tab.
    In this tab navigate to your IAK file and name it in the text box next to where the full file path is displayed.
    In the Browse FieldPoint Tab of the same window you should now be able to see all of your FieldPoint modules and channels. 
    Message Edited by BLAQmx on 03-06-2008 01:12 PM
    Mark
    LabVIEW R&D

  • Socket.InputStream.read()

    public ServerThread(ThreadGroup t, Socket con,lServer master, int clientId) {
         super(t, "server");
         this.con = con;
         this.master = master;
         this.clientId = clientId;
    void run(){
        int task = 0;
        try {
            out = new DataOutputStream(con.getOutputStream());
            in = con.getInputStream();
            out.write(job.KN_NewClientID);
            out.write(clientId);
        } catch (IOException e) {
            melde("\nIOException  in run : " + e);
            return;
         * Start waiting for input
        while (true) {
            try {
           *   next line conecersn my question
           *===========================
                task = in.read();
                switch (task) {
                  // more          
            } catch (IOException e) {
                System.out.println("IOException  Serverthread  : " + );
                return;
    }When the above ( code-snippet) Thread is waiting for input
    task = in.read();
    In I create another thread, which will try to send and receive with the same socket in and -out.
    does the above thread block the second ?
    and if so, how do I avoid this
    TIA
    Hanns

    i like this forum: http://forum.java.sun.com/forum.jspa?forumID=11
    as for the question,
    http://java.sun.com/developer/onlineTraining/Programming/BasicJava2/socket.html#sockets
    what i can get from this, is have a listener, listen for new connections, every connection established, create a new thread, these threads will have their own input and output streams, so you wont have to worry bout watchyamacallits
    then again, your threadgroups, im not following your code, but all i can say, is the socket examples work

Maybe you are looking for

  • Adding Button to a form

    Hi I'm trying to add a new button to a form, here is my code:         objForm = SBO_Application.Forms.GetForm("992", "1")         objForm.Items.Add("btnHelp", BoFormItemTypes.it_BUTTON)         btnHelp = objForm.Items.Item("btnHelp").Specific        

  • HT1338 Please inform if I must to backup my app before upgrade or my app will be here with the new update

    If I want to upgrade my operating system I must to backup my old app or they will be thare after the upgrade .

  • How to restart Broadcast agent console server in unix environment

    Hi All,   I have big issue.. When the BCA server shutting down automatically but its not restarting automatically in UNIX environment. So automatic shutdown facility resulting in BCA staying inactive! So could you please help me how to enable the par

  • Lost a view

    I have my Mail setup so that all received emails are visible at the top of the screen and whatever email is highlighted is visable below the received emails. I know that this is an easy fix, but I cannot find it. Someone got on my computer and change

  • Pages take forever to load up using wifi

    When ever i go on safari or even apps using wifi, they just won't load up or they just take a awfully long time, ive powered off my phone and put it back on, and even restored it through i tunes it on my pc !! But it's till the same this has only rea