Java Sockets and Output Streams

Hi All,
I am beginning sockets programming and I have a problem. If there is a server listening in the background for incoming connections and say for example 4 client programs programs which we shall call client1...client4 connect. How best can I capture the output streams associated with these newly created sockets so that the server can send back isome nformation to say clients1 and client4 only which is not seen by clients 2 and 3. Similarly I would like the server to send some infor to clients 2 and 3 only which is not seen by client1 and client 4.
Currently I have the server listening part as shown below, but not too sure how to add DISTINCT output streams for 1 and 4 on one hand and 2 and 3 on the other.
Thanks:
// bind socket to a port number
ServerSocket serverSocket = new ServerSocket(portNo);
// create socket to listen to client connection
while (true) {
//listen to an incoming connection
System.out.println("chatroom server waiting for incoming connections");
Socket incomingSocket = serverSocket.accept();
//launch new thread to take care of new connection
chatRoomThread chatThread = new chatRoomThread(incomingSocket);
chatThread.start();
//go back and wait for next connection
Please help.
Thanks,
Bleak

HouseofHunger wrote:
yes thats exactly the way I have my in and out streams, in the run method, but that doesn't help me in filtering traffic, in other words I am saying 2 clients, client1 and client4 for example should share a common in and out stream so that they will see eact other's messages... makes sense.....?No, doesn't make sense. That's the wrong design. Each socket should have its own input and output stream (yes, I know, that's been said several times before). If messages going to client1 should also be sent to client4, then whatever writes the messages to client1's output stream must also write them to client4's output stream. Trying to make those two output streams actually be the same output stream is the wrong way to do that. Just have the controller send the messages to whoever is supposed to get them.

Similar Messages

  • Java Input and Output streams

    I have maybe simple question, but I can`t really understand how to figure out this problem.
    I have 2 applications(one on mobile phone J2ME, one on computer J2SE). They commuinicate with Input and Output Streams. Everything is ok, but all communication is in sequence, for example,
    from mobile phone:
    out.writeUTF("GETIMAGE")
    getImage();
    form computer:
    reply = in.readUTF();
    if(reply.equals("GETIMAGE")) sendimage()
    But I need to include one simple thing in my applications - when phone rings there is function in MIDlet - pauseApp() and i need to send some signal to Computer when it happens. But how can i catch this signal in J2SE, because mayble phone rings when computer is sending byte array? and then suddnely it receives command "RINGING"....?
    Please explain how to correcly solve such problem?
    Thanks,
    Ervins

    Eh?
    TCP/IP is not a multiplexed protocol. And why would you need threads or polling to decipher a record-oriented input stream?
    Just send your images in packets with a type byte (1=command, 2=image, &c) and a packet length word. At the receiver:
    int type = dataInputStream.read();
    int length = dataInputStream.readInt();
    byte[] buffer = new byte[length];
    int count, read = 0;
    while ((count = dataInputStream.read(buffer,count,buffer.length)) > 0)
    read += count;
    // At this point we either have:
    // type == -1 || count = -1 => EOF
    // or count > 0, type >= 0, and buffer contains the entire packet.
    switch (type)
    case -1:
    // EOF, not shown
    break;
    case COMMAND: // assuming a manifest constant somewhere
    // process incoming command
    break;
    case IMAGE:
    // process or continue to process incoming image
    break;
    }No threads, no polling, and nuthin' up my sleeve.
    Modulo bugs.

  • MultiThreading with Input and Output Streams

    Hi,
    I have a problem and I think it's because I'm not coding correctly. Please help me if you can understand what I'm doing wrong.
    I have a server that spawns a separate thread to go off and collect data from a serial port. It also waits to accept connections from any client and if a connection is made it will send that data to the clients connected.
    There is data constantly coming in through the serial port. It is output through a DataOutputStream so when the thread is created in the server, I pipe it into a DataInputStream. I do does because I want the server to then read in the data from the inputstream and then send it out to all my clients.
    So far, the way I have it set up seems to do this. But my problem occurs when I try to close a client connection. Instead of removing the socket connection it gives me an error that it can't send data to the client, but it shouldn't be sending data to the client because I just closed it. I realize this is probably because I'm still constantly receiving data from my inputstream and the connection was closed so it can't send that data to the client. I know I need to either close the stream or close my socket but I don't know where this needs to be done. I'm stuck on the correct way to fix this.
    My second problem is the initial connection made to receive data from the inputstream. This is probably because I'm not very familiar with how input/output streams work. But instead of just sending the client the current data being received in real time, it'll send all the data that's buffered in the inputstream. I don't want all the data that's been collecting to go to that first client. I only want the recent data that is coming through while the client is connected. Does this make sense? Because after I make a second client connection I don't have this problem because the InputStream is no longer buffered up. Should I be using something else besides the DataInputStream?
    I feel like I'm going about this the wrong way. Please advise. I'm shy about showing the code but I've included the bulk of it here in hopes that someone will see what I'm doing wrong. The only part that's left out is the thread that reads from the serial port. I don't seem to have any problems with that thread.
    Thanks,
    kim
    ===
    import java.io.*;
    import java.net.*;
    import javax.comm.*;
    import java.util.*;
    // DataServer waits for a client connection
    class DataServer
         static final int PORT = 7;
         // The ServerSocket to use for accepting new connections
         private ServerSocket ss;
         // A mapping from sockets to DataOutputStreams. This will
         // help us avoid from having to create a DataOutputStream each time
         // we want to write to a stream.
         private Hashtable outputStreams = new Hashtable();
         // The inputstream that will receive serial port data through a
         // piped inputstream
         public DataInputStream datalogger;
         // Constructor and while-accept loop all in one.
         public DataServer() throws IOException
              try {
                   // Creating pipe to convert the outputstream from the
                   // RS232 Thread to an inputstream for the server to read
                   PipedOutputStream pout = new PipedOutputStream();
                   PipedInputStream pin = new PipedInputStream(pout);
                   // The inputstream that will receive data from the RS232Thread
                   datalogger = new DataInputStream(pin);
                   // Spawn the thread that will read data through from
                   // the TINI serial port
                   new RS232Thread( pout ).start();
                   // Begin listening for connections and send data
                   listen();
              } catch (IOException ioe) {
                   System.out.println("Error >> DataServer::DataServer()");
                   System.out.println(ioe.getMessage());
                   ioe.printStackTrace();
              } finally {
                   try     {
                        System.out.println( "Closing >> DataServer::DataServer()" );
                        datalogger.close();
                   } catch (IOException i ) {
                        System.out.println( "Error2 >> DataServer::DataServer()" );
                        System.out.println(i); }
         private void listen() throws IOException
              // Create the ServerSocket
              ss = new ServerSocket( PORT );
              // Inform that the server is ready to go
              System.out.println( "Listening on " + ss );
              // Keep accepting connections forever
              while (true) {
                   // Grab the next incoming connection
                   Socket s = ss.accept();
                   // Inform that connection is made
                   System.out.println( "Connection from " + s );
                   // Create a DataOutputStream for writing data to the
                   // other side
                   DataOutputStream dout = new DataOutputStream( s.getOutputStream() );
                   // Save this stream so we don't need to make it again
                   outputStreams.put( s, dout );
                   // Create a new thread for this connection, and then foret
                   // about it
                   new ServerThread( this, s );
         // Get an enumeration of all the OutputStreams, one for each client
         // connected to the server
         Enumeration getOutputStreams() {
              return outputStreams.elements();
         // Send a message to all clients (utility routine)
         void sendToAll( byte[] b ) {
              // synchronize on this because another thread might be
              // calling removeConnection() and this would screw things up
              // while it walks through the list
              synchronized( outputStreams ) {
                   // For each client...
                   for (Enumeration e = getOutputStreams(); e.hasMoreElements();) {
                        // ... get the output stream ...
                        DataOutputStream dout = (DataOutputStream)e.nextElement();
                        // ... and send the message
                        try {          
                             dout.write( b );
                        } catch(IOException ie) {                     
                             System.out.println( "Error >> ServerThread::sendToAll()" );
                             System.out.println( ie );
         // remove a socket, and it's corresponding output stream, from the
         // list. This is usually called by a connection thread that has
         // discovered that the connection to the client is dead.
         void removeConnection( Socket s ) {
              // Synchronize so it doesn't mess up sendToAll() while it walks
              // down the list of all output streams
              synchronized( outputStreams ) {
                   // Inform about removal
                   System.out.println( "Removing connection to " + s );
                   // Remove if from our hastable/list
                   outputStreams.remove( s );
                   // Make sure it's closed
                   try {
                        s.close();
                   } catch( IOException ie ) {
                        System.out.println( "Error closing " + s );
                        ie.printStackTrace();
         // main - Opens a server socket and spins off a new thread each time
         // a new client connection is accepted on this socket.
         public static void main(String[] args) throws Exception
              System.out.println("Starting DataServer version 1.0 ...");
              try     
                   new DataServer();
              catch (IOException ioe)
                   System.out.println( "Error >> DataServer::main()" );
                   System.out.println(ioe.getMessage());
                   ioe.printStackTrace();
    class ServerThread extends Thread
         //The Server that spawned this thread
         private DataServer server;
         // The Socket connected to the client
         private Socket socket;
         //Constructor
         public ServerThread( DataServer server, Socket socket )
              // save the parameters
              this.server = server;
              this.socket = socket;
              // Start up the thread
              start();
         // This runs in a separate thread when start() is called in the
         // constructor
         public void run() {
              try {
                   // The inputstream receiving data from the global inputstream
                   // that is piped to the RS232 Thread
                   // ???? is this where i'm messing up ???
                   DataInputStream in = new DataInputStream( server.datalogger );
                   int num = 0;
                   byte[] d = new byte[1];
                   // read from the inputstream over and over, forever ...
                   while( ( num = in.read(d) ) > 0 ) {
                        // ... and have the server send it to all clients
                        server.sendToAll( d );               
              } catch (IOException ioe) {
                   System.out.println( "Error >> ServerThread::run()" );
                   System.out.println(ioe.getMessage());
                   ioe.printStackTrace();
              } finally {
                   // The connection is closed for one reason or another,
                   // so have the server dealing with it
                   System.out.println( "Closing" );
                   server.removeConnection( socket );

    A couple of things to note...
    First, you are looping infinitely in your server's constructor. Since the constructor is never completing, your server object is never completely constructed - this may cause indeterminate behaviour when you pass a reference to the server to another thread.
    Second, I would recommend fixing your issues by modifying your design somewhat. The design I would recommend (read: The design I would use) is:
    A server object, with a public listen method. The constructor spawns a thread to constantly read from the serial port and forward the data read back to the server, via a multicast (sendToAll) method.
    The listen method sets up a server socket to accept connections, and in a loop opens client sockets and stores them in a set.
    The multicast method iterates through the list of open client sockets, and for each in turn confirms that it is still open. If open, send the data down the socket's output stream; if closed, remove the socket from the set.
    Note that this design includes only two threads - the main thread listens for and accepts new socket connections, while the extra thread collects data from the serial port, multicasts it to all of the open sockets, and removes all of the closed sockets. If you require to perform any other communication with the sockets, it may be necessary to create a thread for those sockets, to facilitate reading from their input streams, but in the given design, this is not necessary.
    I hope this helps,
    -Troy

  • Separate thread for input stream and output stream.

    Hi Techies,
    In a socket connection, can we run the input stream and output stream in separate threads. actually in my case, the input stream will be getting the input regularly and output stream will send data very rare. so if i impelment them in one class then unless there is data to send output stream will be blocked. i was thinking to impelment both the streams in separate threads. is it a good way? so how to implement it. your guidance will be of great help.
    thanks in advance.

    JavaBreather wrote:
    Hi Techies,
    In a socket connection, can we run the input stream and output stream in separate threads.I would say this is the most common way of handling sockets and threads. esp pre-NIO.
    Iis it a good way? so how to implement it. your guidance will be of great help.Once you have a socket, create two threads, one which does the reading and one which does the writing.
    You could use BlockingQueues to abstract access to these threads. i.e. the reading thread reads something from the socket and adds it to the BlockingQueue. The writing thread take()s something froma second BlockingQueue and writes it to the Socket. This way you add things to write or get thing to process by looking at the BlockingQueues.

  • Java.lang.IllegalStateException : output stream already retrived Error

    Hi All
    I am trying to integrate crystal reports 10g with oracle 10g AS.My application works fine on TOMCAT 4.1.31,but when I depoly in oracle 10G AS,it shows the following exception
    Java.lang.IllegalStateException : output stream already retrived.
    Any suggestions?
    Regards
    Mohan

    Hello,
    Awaiting help.
    Thanks and Regards
    Mohan

  • Java.lang.IllegalStateException : output stream already retrived.

    Hi All
    I am trying to integrate crystal reports 10g with oracle 10g AS.My application works fine on TOMCAT 4.1.31,but when I depoly in oracle 10G AS,it shows the following exception
    Java.lang.IllegalStateException : output stream already retrived.
    Any suggestions?
    Regards
    Mohan

    Hello,
    Awaiting help.
    Thanks and Regards
    Mohan

  • Fileinput and output stream

    hi. i was trying to learn this fileinput and output stream in java. i was trying to solve this exercise problem in which a user need to ask for the inputfile (Which i have created mydata.txt which has 5 positive numbers and 5 negative numbers ). my program will ask the user for the input file and then output the results in 2 seperate files one output will be for positive integers which the program will extract from myData,txt and negative integers to another output file. i am very confused. my program does not give me any error msgs but outputs a number 0.
    import java.util.Scanner;
    import java.io.*;
    class fileEg {
         public static void main (String[] args) throws IOException
         int num=0, num1;
         Scanner user = new Scanner(System.in);
         String inputFileName, outputFileName, fileName;
         System.out.println("Input File Name ");
         inputFileName = user.nextLine().trim();
         File input = new File (inputFileName);
         Scanner scan = new Scanner(input);
         System.out.print("Output File Name: ");
        outputFileName = user.nextLine().trim();
        File output = new File( outputFileName );     
        PrintStream  print = new PrintStream( output );     
        while(scan.hasNextInt()) {
             if(num == '+') {
                  print.println( "the numbers are " + num);
             else {
                  print.println("The numbers ares " + num);
             print.close();
    }any help will be really appreciated. any theories or example.
    Thanks

    import java.util.Scanner;
    import java.io.*;
    class fileEg {
         public static void main (String[] args) throws IOException
         int num;
         Scanner user = new Scanner(System.in);
         String inputFileName, outputFileName, negativeFileName;
         System.out.println("Input File Name ");
         inputFileName = user.nextLine().trim();
         File input = new File (inputFileName);
         Scanner scan = new Scanner(input);
         System.out.print("Output File positive Name: ");
        outputFileName = user.nextLine().trim();
        File output1 = new File( outputFileName );     
        PrintStream  positiveNumbers = new PrintStream( output1 ); 
        System.out.print("Output File negative Name: ");
        negativeFileName = user.nextLine().trim();
        File output = new File( negativeFileName );     
        PrintStream  negativeNumbers = new PrintStream( output ); 
    while(scan.hasNextInt()) {
             num= scan.nextInt();
             if (num >0) {
                  positiveNumbers.println( "the numbers are " + num);
             } else {
                  negativeNumbers.println("The numbers ares " + num);
    positiveNumbers.close();
    negativeNumbers.close();
    }Thanks paul
    Message was edited by:
    fastmike

  • Java sockets and raw sockets

    Hello!
    I have made my own file sharing program with Java sockets
    and i have read a litle bit about raw sockets also.
    What are the differences between Java sockets and raw sockets?

    raw socket can have packet types which Java does not.
    Generally if you need something useful which Java cannot do there is a utility already written which does what you want, e.g. ping and you can call that.

  • Socket input / output stream

    Does anyone know if the input / output streams returned by getInputStream() / getOutputStream() in java.net.Socket are buffered by default?

    y they are buffered, but to use the buffer, you have to use available() and read(byte[] buf ...

  • ObjectInput and Output streams

    Hi all,
    What is objectInput and Out Stream? For what purpose we r using it?
    regards,
    Mahe

    From the Standard Java API
    An ObjectInputStream deserializes primitive data and objects previously written using an ObjectOutputStream.
    ObjectOutputStream and ObjectInputStream can provide an application with persistent storage for graphs of objects when used with a FileOutputStream and FileInputStream respectively. ObjectInputStream is used to recover those objects previously serialized. Other uses include passing objects between hosts using a socket stream or for marshaling and unmarshaling arguments and parameters in a remote communication system.
    ObjectInputStream ensures that the types of all objects in the graph created from the stream match the classes present in the Java Virtual Machine. Classes are loaded as required using the standard mechanisms.
    Only objects that support the java.io.Serializable or java.io.Externalizable interface can be read from streams.
    The method readObject is used to read an object from the stream. Java's safe casting should be used to get the desired type. In Java, strings and arrays are objects and are treated as objects during serialization. When read they need to be cast to the expected type.
    Primitive data types can be read from the stream using the appropriate method on DataInput.
    The default deserialization mechanism for objects restores the contents of each field to the value and type it had when it was written. Fields declared as transient or static are ignored by the deserialization process. References to other objects cause those objects to be read from the stream as necessary. Graphs of objects are restored correctly using a reference sharing mechanism. New objects are always allocated when deserializing, which prevents existing objects from being overwritten.
    Reading an object is analogous to running the constructors of a new object. Memory is allocated for the object and initialized to zero (NULL). No-arg constructors are invoked for the non-serializable classes and then the fields of the serializable classes are restored from the stream starting with the serializable class closest to java.lang.object and finishing with the object's most specific class.
    For example to read from a stream as written by the example in ObjectOutputStream:
         FileInputStream fis = new FileInputStream("t.tmp");
         ObjectInputStream ois = new ObjectInputStream(fis);
         int i = ois.readInt();
         String today = (String) ois.readObject();
         Date date = (Date) ois.readObject();
         ois.close();
    Classes control how they are serialized by implementing either the java.io.Serializable or java.io.Externalizable interfaces.
    Implementing the Serializable interface allows object serialization to save and restore the entire state of the object and it allows classes to evolve between the time the stream is written and the time it is read. It automatically traverses references between objects, saving and restoring entire graphs.
    Serializable classes that require special handling during the serialization and deserialization process should implement the following methods:
    private void writeObject(java.io.ObjectOutputStream stream)
    throws IOException;
    private void readObject(java.io.ObjectInputStream stream)
    throws IOException, ClassNotFoundException;
    private void readObjectNoData()
    throws ObjectStreamException;
    The readObject method is responsible for reading and restoring the state of the object for its particular class using data written to the stream by the corresponding writeObject method. The method does not need to concern itself with the state belonging to its superclasses or subclasses. State is restored by reading data from the ObjectInputStream for the individual fields and making assignments to the appropriate fields of the object. Reading primitive data types is supported by DataInput.
    Any attempt to read object data which exceeds the boundaries of the custom data written by the corresponding writeObject method will cause an OptionalDataException to be thrown with an eof field value of true. Non-object reads which exceed the end of the allotted data will reflect the end of data in the same way that they would indicate the end of the stream: bytewise reads will return -1 as the byte read or number of bytes read, and primitive reads will throw EOFExceptions. If there is no corresponding writeObject method, then the end of default serialized data marks the end of the allotted data.
    Primitive and object read calls issued from within a readExternal method behave in the same manner--if the stream is already positioned at the end of data written by the corresponding writeExternal method, object reads will throw OptionalDataExceptions with eof set to true, bytewise reads will return -1, and primitive reads will throw EOFExceptions. Note that this behavior does not hold for streams written with the old ObjectStreamConstants.PROTOCOL_VERSION_1 protocol, in which the end of data written by writeExternal methods is not demarcated, and hence cannot be detected.
    The readObjectNoData method is responsible for initializing the state of the object for its particular class in the event that the serialization stream does not list the given class as a superclass of the object being deserialized. This may occur in cases where the receiving party uses a different version of the deserialized instance's class than the sending party, and the receiver's version extends classes that are not extended by the sender's version. This may also occur if the serialization stream has been tampered; hence, readObjectNoData is useful for initializing deserialized objects properly despite a "hostile" or incomplete source stream.
    Serialization does not read or assign values to the fields of any object that does not implement the java.io.Serializable interface. Subclasses of Objects that are not serializable can be serializable. In this case the non-serializable class must have a no-arg constructor to allow its fields to be initialized. In this case it is the responsibility of the subclass to save and restore the state of the non-serializable class. It is frequently the case that the fields of that class are accessible (public, package, or protected) or that there are get and set methods that can be used to restore the state.
    Any exception that occurs while deserializing an object will be caught by the ObjectInputStream and abort the reading process.
    Implementing the Externalizable interface allows the object to assume complete control over the contents and format of the object's serialized form. The methods of the Externalizable interface, writeExternal and readExternal, are called to save and restore the objects state. When implemented by a class they can write and read their own state using all of the methods of ObjectOutput and ObjectInput. It is the responsibility of the objects to handle any versioning that occurs.
    Edited by: pgeuens on Dec 26, 2007 1:50 PM

  • Java.lang.Process output stream problem

    Hi, I have a program that starts a process (java.lang.Process) using the java.lang.Runtime.exec() and it attemtps to interface with it using the provieded io streams. I have both the output and error streams being handled on their own threads and I have a hashmap of output lines/command pairs that are checked so that when the process outputs certain lines to the console it feed the proper input into the process. My problem is that when I feed the input into the process it dosen't respond to it almost like the user hasn't pressed enter, The process hangs. I have tried using /n /r and permutations thereof but nothing works. The thread does read the lines from the process and does output to the process from what i can gather. Can you help me!
    here is some of the code..
    public void run() {
    try {
         //the process's output
         InputStreamReader isrOutput = new InputStreamReader(inOutput);
         //the process's input(our output)
         PrintWriter pw = new PrintWriter(outInput);
         String line = null;
         while(true){
              if(brOutput.ready()){
                   line = "";
                   while(brOutput.ready())
         line+=(char)brOutput.read();
                   System.out.print(line);
                   if(commands.containsKey(line)){
         pw.println((String)commands.get(line));
         System.out.println((String)commands.get(line));;
    } catch (IOException ioe) {
              ioe.printStackTrace();
    }Thanks

    Oops.. i forgot to flush my PrintWriter /blushing......... Thanks

  • Input and output streams

    I am struggling with this, if any of you have any advice I would appreciate it.
    I am creating a java server that can communicate with a client over tcp sockets and to a device through a serial port. I have have the TCP part all set up. I found this packet and code to be able to communicate through a serial port.
    http://rxtx.qbang.org/wiki/index.php/Two_way_communcation_with_the_serial_port
    it works by itself, but I don't think I can make it work with my server because I am already using a system.in for the tcp portion of it. In the long run what I want to be able to do is take information from the socket connection, play with it a little bit, and then send it out the serial port to the device.
    Is it possible to convert this code to instead of asking for input from the keyboard, to take a string that I can pass in from somewhere, or if something comes in on the serial port to write it to a string or something?

    Sorry I was so vague.
    this code that i found on the website, creates a connection with the serial port, then it waits for input from the keyboard. once that input comes in, it sends out that stuff through the serial port. I want it to instead of wanting for input from the keyboard, to check to see if there is something in a string or something, if there is write it out to the serial port.
    Basically instead of having a listener constantly waiting for input from the keyboard, be able to call a method from the rest of my program to send stuff out the serial port.

  • Is there a way to flush out a socket's output stream without...

    ...having to close it (the stream)?
    I'm trying to implement a keep-alive feature in a simple HTTP Server application. This is a draft of the code I have trouble with:
    ==========
    //'clientSocket' is the socket obtained by the 'serverSocket.accept()' method
    OutputStream out = clientSocket.getOutputStream();
    //'message' is a string to be sent to the client
    InputStream data = new ByteArrayInputStream(message.getBytes());
    byte[] buff = new byte[2048];
    while (true)
    int read = data.read(buff, 0, 2048);
    if (read <= 0)
    break;
    out.write(buff, 0, read);
    out.flush();
    ==========
    If I don't call 'out.close()', the data will not be sent to the client.
    If I call 'out.close()', the data will be sent, but the socket will be closed too, which I don't want to. I need to be able to reuse that socket .
    Is there any way to properly push out the data to the client without having to close the output stream?

    ...having to close it (the stream)?Yes. OutputStream.flush(). But if you're not using any kind of buffered writer/output stream you don't even have to do that.
    If I don't call 'out.close()', the data will not be sent to the client.Untrue. The client will read everything that has been written If you don't close the output stream, the client will never get the EOS indication (e.g. read() returning -1). So if your client is looping until that happens it will loop forever ...
    Your problem at the moment is at the reading end.

  • Java sockets and winsock

    when I use java socket to talk to my proxy, without going through a winsock, my java applet runs fine. However, when I patch winsock in between my java gui and my other proxy, I dont receive anything in the gui. I snoop at packets coming from my other proxy through winsock to my gui and the data is all there. I just cannot receive it.
    I use java class DatagramSocket() to establish a socket connection and use class DatagramPacket to get the packets coming. This works if I dont go through a ms proxy.
    Can anyone tell me why?

    How can you snoop at packets comming? I need to know so bad. :-)
    Thank you

  • Pipes (Input- and Output-streams) to a Process are not closed

    Hello experts!
    I have a long-living server-process that opens external programs with
    Runtime.getRuntime().exec() all the time. For communication with one
    of the external program I use stdin and stdout. I close all streams in
    finally-blocks, so there should not be any open stream.
    The problem is, that most of the time the used streams are closed
    correctly. But sometimes some of them left open. I check that with
    the linux command-line tool lsof. So over time the number of open
    pipes increases and eat up all file-handles till an IOException (too
    many open files) is thrown.
    If I watch the -verbosegc output, I see that most of the open pipes
    are cleaned up after a GC-run. But over time - not all.
    I start the external program in a thread, what could explain that
    it happens only sometimes.
    I'm hunting this bug now for quite a long time. Are there any known
    problems with using pipes to/from other processes (under linux?)
    thanks
    lukas

    Hi!
    Now I did some heavy logging and I saw that the remaining pipes are the ones I DON'T
    open to read or write! No joke! For example - for one process I don't read or write any of
    stdin,stdout,stderr - then in one of X executions all three pipes are left open (shown by
    lsof for the java-process, after many GC-runs).
    To test it I read the stdin of this process - then this stream was closed in the error case,
    but stdout and stderr are still open. This is really strange!
    anybody seen this before?
    lukas

Maybe you are looking for

  • Squeezed Image in QuickTime from FCP

    Although I've come close to finding my specific issue when perusing the discussions, I haven't had much success. I shot in 16:9 on the XL2. I changed all my settings in FCP before logging and capturing to accommodate this. It looks fine in FCP, inclu

  • Electrical​/Software (LabVIEW) Design Engineer, Wiltshire, UK

    Job Title: Electrical/Software (LabVIEW) Design Engineer Job Type: Permanent Location: Malmesbury, Wiltshire, UK Job Purpose: To provide design solutions for machine control, instrumentation and data acquisition using National Instruments LabVIEW. Su

  • Newest Update may have caused my Itunes to start crashing at startup

    Ok, my once a week auto Mac auto update just finished and now my itunes 10.6 will start then crash as soon as it opens. Error report as follows Process:         iTunes [746] Path:            /Applications/iTunes.app/Contents/MacOS/iTunes Identifier: 

  • Red screen / Alert when using a Theme - help

    I'm on version 10.0.9 of FCPX (just updated to the latest version) and IOS 8 but I'm seeing this alert/red screen when trying to use some new plugin themes.  Can anybody help tell me what I'm doing wrong?  Do I need motion just to use some themes? 

  • How to get Correct curent time and date

    Hi, I would like to know whether system keeps updating SY-UZEIT each second or it contains the time value when the program was started. Suppose a program starts at 12:00:00 time and takes 10 sec to finish. Will I get same value of SY-UZEIT or will i