Microphone Streaming over Network is Choppy

Hello.
Part of a program in development allows audio to be streamed over the Internet via microphone capture. The current solution seems to be working alright... however, at times the audio gets extremely choppy on the receiving side, almost to the point of being unable to hear it at all... 15 second gaps etc...
I was wondering if you would look at this code and had any suggestions how I could improve this to make it flow better.
Any help is appreciated. First is the server code. Second is the client (receiving code)
public class MicrophoneManager implements Runnable {
private static volatile ByteArrayOutputStream byteArrayOutputStream;
private static String communicatorIP = null;
public static volatile boolean interrupt = false;
private AudioFormat getAudioFormat() {
float sampleRate = 8000.0F;
//8000,11025,16000,22050,44100
int sampleSizeInBits = 8;
//8,16
int channels = 1;
//1,2
boolean signed = true;
//true,false
boolean bigEndian = false;
//true,false
return new AudioFormat(
sampleRate,
sampleSizeInBits,
channels,
signed,
bigEndian);
}//end getAudioFormat
public static void setCommunicatorIP(String communicatorIP) {
MicrophoneManager.communicatorIP = communicatorIP;
@Override
public void run() {
try {
AudioFormat audioFormat = getAudioFormat();
DataLine.Info dataLineInfo = new DataLine.Info(TargetDataLine.class, audioFormat);
TargetDataLine targetDataLine = (TargetDataLine) AudioSystem.getLine(dataLineInfo);
targetDataLine.open(audioFormat);
targetDataLine.start();
ArrayList<Byte> byteArrayList = new ArrayList<Byte>();
byte tempBuffer[] = new byte[10000];
byteArrayOutputStream = new ByteArrayOutputStream();
Thread mcThread = new Thread(new MicrophoneCommunicator());
mcThread.start();
//bos = new BufferedOutputStream(byteArrayOutputStream);
while (!interrupt) {
while (byteArrayList.size() < 10000) {
targetDataLine.read(tempBuffer, 0, tempBuffer.length);
for (byte b : tempBuffer) {
byteArrayList.add(b);
byte[] writerArray = new byte[byteArrayList.size()];
tempBuffer = new byte[10000];
for (int i = 0; i < byteArrayList.size(); i++) {
writerArray[i] = byteArrayList.get(i);
byteArrayList.clear();
byteArrayOutputStream.write(writerArray, 0, writerArray.length);
targetDataLine.close();
} catch (Exception e1) {
global.debug(e1);
private class MicrophoneCommunicator implements Runnable {
public void run() {
try {
Socket microphoneSocket = new Socket(communicatorIP, 5751);
BufferedOutputStream netStreamOut = new BufferedOutputStream(microphoneSocket.getOutputStream());
while (!interrupt) {
if (byteArrayOutputStream.toByteArray().length >= 10000) {
netStreamOut.write(byteArrayOutputStream.toByteArray());
byteArrayOutputStream.reset();
microphoneSocket.close();
} catch (Exception e1) {
global.debug(e1);
}Now, here is the other code.
public class Microphone implements Runnable {
public void run() {
try {
byte[] tempArray = new byte[10000];
ServerSocket micSocket = new ServerSocket(5751);
micSocket.setSoTimeout(0);
Socket microphoneSocket = micSocket.accept(); //Now connected
BufferedInputStream bis = new BufferedInputStream(microphoneSocket.getInputStream());
ByteArrayInputStream bais = new ByteArrayInputStream(tempArray);
AudioFormat audioFormat = getAudioFormat();
AudioInputStream audioInputStream =
new AudioInputStream(bais,
audioFormat,
tempArray.length / audioFormat.getFrameSize());
DataLine.Info dataLineInfo =
new DataLine.Info(
SourceDataLine.class,
audioFormat);
SourceDataLine sourceDataLine = (SourceDataLine) AudioSystem.getLine(
dataLineInfo);
sourceDataLine.open(audioFormat);
sourceDataLine.start();
ArrayList<Byte> byteArrayList = new ArrayList<Byte>();
boolean interrupted = false;
while (!interrupted) {
int nextByte = 0;
while ((nextByte = bis.read()) != -1 && (byteArrayList.size() < 10000)) {
byteArrayList.add((byte) nextByte);
for (int i = 0; i < byteArrayList.size(); i++) {
tempArray[i] = byteArrayList.get(i);
byteArrayList.clear();
sourceDataLine.write(tempArray, 0, tempArray.length);
interrupted = global.micInterrupt;
microphoneSocket.close();
micSocket.close();
sourceDataLine.close();
} catch (Exception e1) {
e1.printStackTrace();
private AudioFormat getAudioFormat() {
float sampleRate = 8000.0F;
//8000,11025,16000,22050,44100
int sampleSizeInBits = 8;
//8,16
int channels = 1;
//1,2
boolean signed = true;
//true,false
boolean bigEndian = false;
//true,false
return new AudioFormat(
sampleRate,
sampleSizeInBits,
channels,
signed,
bigEndian);
}//end getAudioFormat
}If you guys have any ideas on how to make this smoother... please feel free... Also, please feel free to use this code however you wish. I'd really appreciate this... It's hard for people to communicate when it's so choppy this way.
However, the stream is currently only one way though, it only goes from one system to another... not two-way. One talks, the other types... it's complicated, but just might be useful info.
Both sides are communicating via lan... so speed of connection isn't an issue...
Thanks in advance.
Best,
Chris

I'd recommend using UDP streams instead of TCP streams, and I'd recommend discarding out-of-order packets and packets that are delayed beyond a certain threshold (which you can play with)...

Similar Messages

  • Microphone streaming over SIP protocol.

    Hello,
    can I stream microphone voice over SIP protocol?
    Is there a library to use SIP protocol without RTMP communication?
    thanks

    I'd recommend using UDP streams instead of TCP streams, and I'd recommend discarding out-of-order packets and packets that are delayed beyond a certain threshold (which you can play with)...

  • IPhone HE-AAC Streaming over Mobile Network (3G)

    Developed an internet radio streamer using utilizing the html5 audio tags with jQuery and with a flash fall back for unsupported browsers, streaming through an icecast2 server. Upon testing the player on the iPhone Safari (iOS 5.0.1), we ran into a very peculiar issue.
    When the iPhone is connected to WiFi, it streams perfectly using the HE-AAC V2 stream @ 64kbps 44.1kHz (the preferred codec for apple products). However, when the iPhone is connected to the 3G mobile network (ATT and Verizon), it "stutters/buffers" or stops streaming for 1-2 secs every 1-2 minutes (does not stop streaming completely). The troubling thing is when the iPhone is forced to use a separate MP3 stream at the same bit rate, it does not have this issue and works very well on 3G.

    Hi Lawrence,
    Thanks for the fast response. I'm confused as to how AAC requires higher bandwidth over MP3 when it can produce higher quality audio at lower bit rates therefore requiring less bandwidth to stream over 3G. Are you referring to the bandwidth of the audio signal itself (at the codec level)?

  • Help! Saving an image to stream and recreating it on client over network

    Hi,
    I have an application that uses JDK 1.1.8. I am trying to capture the UI screens of this application over network to a client (another Java app running on a PC). The client uses JDK 1.3.0. As AWT image is not serializable, I got code that converts UI screens to int[] and persist to client socket as objectoutputstream.writeObject and read the data on client side using ObjectInputStream.readObject() api. Then I am converting the int[] to an Image. Then saving the image as JPEG file using JPEG encoder codec of JDK 1.3.0.
    I found the image in black and white even though the UI screens are in color. I have the code below. I am sure JPEG encoder part is not doing that. I am missing something when recreating an image. Could be colormodel or the way I create an image on the client side. I am testing this code on a Win XP box with both server and client running on the same machine. In real scenario, the UI runs on an embedded system with pSOS with pretty limited flash space. I am giving below my code.
    I appreciate any help or pointers.
    Thanks
    Puri
         public static String getImageDataHeader(Image img, String sImageName)
             final String HEADER = "{0} {1}x{2} {3}";
             String params[] = {sImageName,
                                String.valueOf(img.getWidth(null)),
                                String.valueOf(img.getHeight(null)),
                                System.getProperty("os.name")
             return MessageFormat.format(HEADER, params);
         public static int[] convertImageToIntArray(Image img)
             if (img == null)
                 return null;
            int imgResult[] = null;
            try
                int nImgWidth = img.getWidth(null);
                int nImgHeight = img.getHeight(null);
                if (nImgWidth < 0 || nImgHeight < 0)
                    Trace.traceError("Image is not ready");
                    return null;
                Trace.traceInfo("Image size: " + nImgWidth + "x" + nImgHeight);
                imgResult = new int[nImgWidth*nImgHeight];
                PixelGrabber grabber = new PixelGrabber(img, 0, 0, nImgWidth, nImgHeight, imgResult, 0, nImgWidth);
                grabber.grabPixels();
                ColorModel model = grabber.getColorModel();
                if (null != model)
                    Trace.traceInfo("Color model is " + model);
                    int nRMask, nGMask, nBMask, nAMask;
                    nRMask = model.getRed(0xFFFFFFFF);
                    nGMask = model.getRed(0xFFFFFFFF);
                    nBMask = model.getRed(0xFFFFFFFF);
                    nAMask = model.getRed(0xFFFFFFFF);
                    Trace.traceInfo("The Red mask: " + Integer.toHexString(nRMask) + ", Green mask: " +
                                    Integer.toHexString(nGMask) + ", Blue mask: " +
                                    Integer.toHexString(nBMask) + ", Alpha mask: " +
                                    Integer.toHexString(nAMask));
                if ((grabber.getStatus() & ImageObserver.ABORT) != 0)
                    Trace.traceError("Unable to grab pixels from the image");
                    imgResult = null;
            catch(Throwable error)
                error.printStackTrace();
            return imgResult;
         public static Image convertIntArrayToImage(Component comp, int imgData[], int nWidth, int nHeight)
             if (imgData == null || imgData.length <= 0 || nWidth <= 0 || nHeight <= 0)
                 return null;
            //ColorModel cm = new DirectColorModel(32, 0xFF0000, 0xFF00, 0xFF, 0xFF000000);
            ColorModel cm = ColorModel.getRGBdefault();
            MemoryImageSource imgSource = new MemoryImageSource(nWidth, nHeight, cm, imgData, 0, nWidth);
            //MemoryImageSource imgSource = new MemoryImageSource(nWidth, nHeight, imgData, 0, nWidth);
            Image imgDummy = Toolkit.getDefaultToolkit().createImage(imgSource);
            Image imgResult = comp.createImage(nWidth, nHeight);
            Graphics gc = imgResult.getGraphics();
            if (null != gc)
                gc.drawImage(imgDummy, 0, 0, nWidth, nHeight, null);       
                gc.dispose();
                gc = null;       
             return imgResult;
         public static boolean saveImageToStream(OutputStream out, Image img, String sImageName)
             boolean bResult = true;
             try
                 ObjectOutputStream objOut = new ObjectOutputStream(out);
                int imageData[] = convertImageToIntArray(img);
                if (null != imageData)
                    // Now that our image is ready, write it to server
                    String sHeader = getImageDataHeader(img, sImageName);
                    objOut.writeObject(sHeader);
                    objOut.writeObject(imageData);
                    imageData = null;
                 else
                     bResult = false;
                objOut.flush();                
             catch(IOException error)
                 error.printStackTrace();
                 bResult = false;
             return bResult;
         public static Image readImageFromStream(InputStream in, Component comp, StringBuffer sbImageName)
             Image imgResult = null;
             try
                 ObjectInputStream objIn = new ObjectInputStream(in);
                 Object objData;
                 objData = objIn.readObject();
                 String sImageName, sSource;
                 int nWidth, nHeight;
                 if (objData instanceof String)
                     String sData = (String) objData;
                     int nIndex = sData.indexOf(' ');
                     sImageName = sData.substring(0, nIndex);
                     sData = sData.substring(nIndex+1);
                     nIndex = sData.indexOf('x');
                     nWidth = Math.atoi(sData.substring(0, nIndex));
                     sData = sData.substring(nIndex+1);
                     nIndex = sData.indexOf(' ');
                     nHeight = Math.atoi(sData.substring(0, nIndex));
                     sSource = sData.substring(nIndex+1);
                     Trace.traceInfo("Name: " + sImageName + ", Width: " + nWidth + ", Height: " + nHeight + ", Source: " + sSource);
                     objData = objIn.readObject();
                     if (objData instanceof int[])
                         int imgData[] = (int[]) objData;
                         imgResult = convertIntArrayToImage(comp, imgData, nWidth, nHeight);
                         sbImageName.setLength(0);
                         sbImageName.append(sImageName);
            catch(Exception error)
                error.printStackTrace();
             return imgResult;
         }   

    While testing more, I found that the client side is generating color UI screens if I use JDK 1.3 JVM for running the server (i.e the side that generates the img) without changing single line of code. But if I use JDK 1.1.8 JVM for the server, the client side is generating black and white versions (aka gray toned) of UI screens. So I added code to save int array that I got from PixelGrabber to a text file with 8 ints for each line in hex format. Generated these files on server side with JVM 1.1.8 and JVM 1.3. What I found is that the 1.1.8 pixel grabber is setting R,G,B components to same value where as 1.3 version is setting them to different values thus resulting in colored UI screens. I don't know why.

  • Bought a Winegard  indoor HDTV antenna for streaming over-the-air TV. Will my Apple TV work

    FlatWave Mini
    FlatWave
    I Am considering cutting my cable service and have bought a Winegard indoor HDTV wall mount antenna for streaming over-the air tv? I would appreciate an advice you might give me on this project. Will my Apple TV work with this setup? Thanks so much.

    appetv is a media box not a OTA related product in any way
    it use the LAN network to play shared media from your computer
    and if it has an Internet connection it offer a range of Internet streaming services
    read more
    http://www.apple.com/appletv/

  • RTP Streaming over the internet

    Having some problems streaming over the internet - probably because im doing it wrong.
    I can stream over a network fine using Transmit2.java.
    But when i try over the internet cant pick up the stream.
    Im using www.whatismyip.com to get the internet IP of the 2 computers im trying to stream to and from - and using these in the code, but nothing happens.
    Help?

    natdeamer wrote:
    Having some problems streaming over the internet - probably because im doing it wrong.That's correct, you're doing it wrong.
    Im using www.whatismyip.com to get the internet IP of the 2 computers im trying to stream to and from - and using these in the code, but nothing happens.99% of the time, your public IP actually addresses your router, rather than your computer. That means your computer is not publically addressably by it's IP address alone. You'll need to do something called a "NAT holepunch", which you can look up online. Also, I've included two links to discussions I've had with people about the same issue.
    [http://forums.sun.com/thread.jspa?forumID=28&threadID=5355413]
    [http://forums.sun.com/thread.jspa?forumID=28&threadID=5356672]

  • Pulseaudio over network

    Hi, I have a Thinkpad R400 and I also have an ArchLinux i686 home server connected via spdif to my home sound system. When I used debian Lenny, I got really old pulseaudio server, GUI, everything - it worked though. It worked only if I was logged in via X server (graphically) locally or remotely. So I installed Arch (thinking using the same OSes can ease things ... I was so naive) and I cannot get this pulse sound server running. First of all I cannot start pavucontrol over ssh tunnel, it has to be from within logged in session. my /etc/hosts.allow:
    ALL:ALL
    I would like to have the pulseaudio started as a daemon, not having to start X at all. I am unable to start it though. It just says FAILED and gives no reason at all. please tell me what should I do, what how-to should I abide or... Thank you

    Okay, server side /etc/pulse/daemon.conf
    daemonize = yes
    fail = no
    allow-module-loading = no
    allow-exit = no
    use-pid-file = no
    system-instance = yes
    enable-shm = no
    shm-size-bytes = 64 # setting this 0 will use the system-default, usually 64 MiB
    ; lock-memory = no
    ; cpu-limit = no
    ; high-priority = yes
    ; nice-level = -11
    ; realtime-scheduling = yes
    ; realtime-priority = 5
    exit-idle-time = -20
    ; scache-idle-time = 20
    ; dl-search-path = (depends on architecture)
    ; load-default-script-file = yes
    ; default-script-file =
    ; log-target = auto
    ; log-level = notice
    ; log-meta = no
    ; log-time = no
    ; log-backtrace = 0
    ; resample-method = speex-float-3
    ; enable-remixing = yes
    ; enable-lfe-remixing = no
    ; flat-volumes = yes
    ; rlimit-fsize = -1
    ; rlimit-data = -1
    ; rlimit-stack = -1
    ; rlimit-core = -1
    ; rlimit-as = -1
    ; rlimit-rss = -1
    ; rlimit-nproc = -1
    ; rlimit-nofile = 256
    ; rlimit-memlock = -1
    ; rlimit-locks = -1
    ; rlimit-sigpending = -1
    ; rlimit-msgqueue = -1
    ; rlimit-nice = 31
    ; rlimit-rtprio = 9
    ; rlimit-rttime = 1000000
    ; default-sample-format = s16le
    ; default-sample-rate = 44100
    ; default-sample-channels = 2
    ; default-channel-map = front-left,front-right
    ; default-fragments = 4
    ; default-fragment-size-msec = 25
    server side /etc/pulse/system.pa
    ### Automatically load driver modules depending on the hardware available
    .ifexists module-udev-detect.so
    load-module module-udev-detect
    .else
    ### Alternatively use the static hardware detection module (for systems that
    ### lack HAL support)
    load-module module-detect
    .endif
    ### Load several protocols
    .ifexists module-esound-protocol-unix.so
    load-module module-esound-protocol-unix
    .endif
    load-module module-native-protocol-unix
    ### Automatically restore the volume of streams and devices
    load-module module-stream-restore
    load-module module-device-restore
    ### Automatically restore the default sink/source when changed by the user during runtime
    load-module module-default-device-restore
    ### Automatically move streams to the default sink if the sink they are
    ### connected to dies, similar for sources
    load-module module-rescue-streams
    ### Make sure we always have a sink around, even if it is a null sink.
    load-module module-always-sink
    ### Automatically suspend sinks/sources that become idle for too long
    load-module module-suspend-on-idle
    ### Enable positioned event sounds
    load-module module-position-event-sounds
    ### Automatically restore volumes
    load-module module-volume-restore table="/var/pulse/volume-restore.table"
    load-module module-native-protocol-tcp auth-anonymous=1
    #load-module module-native-protocol-tcp
    server side /etc/pulse/default.pa
    .nofail
    ### Load something into the sample cache
    #load-sample-lazy x11-bell /usr/share/sounds/gtk-events/activate.wav
    #load-sample-lazy pulse-hotplug /usr/share/sounds/startup3.wav
    #load-sample-lazy pulse-coldplug /usr/share/sounds/startup3.wav
    #load-sample-lazy pulse-access /usr/share/sounds/generic.wav
    .fail
    ### Automatically restore the volume of streams and devices
    load-module module-device-restore
    load-module module-stream-restore
    load-module module-card-restore
    ### Automatically augment property information from .desktop files
    ### stored in /usr/share/application
    load-module module-augment-properties
    ### Load audio drivers statically (it's probably better to not load
    ### these drivers manually, but instead use module-hal-detect --
    ### see below -- for doing this automatically)
    #load-module module-alsa-sink
    #load-module module-alsa-source device=hw:1,0
    #load-module module-oss device="/dev/dsp" sink_name=output source_name=input
    #load-module module-oss-mmap device="/dev/dsp" sink_name=output source_name=input
    #load-module module-null-sink
    #load-module module-pipe-sink
    ### Automatically load driver modules depending on the hardware available
    .ifexists module-udev-detect.so
    load-module module-udev-detect
    .else
    ### Alternatively use the static hardware detection module (for systems that
    ### lack udev support)
    load-module module-detect
    .endif
    ### Automatically load driver modules for Bluetooth hardware
    .ifexists module-bluetooth-discover.so
    load-module module-bluetooth-discover
    .endif
    ### Load several protocols
    .ifexists module-esound-protocol-unix.so
    load-module module-esound-protocol-unix
    .endif
    load-module module-native-protocol-unix
    ### Network access (may be configured with paprefs, so leave this commented
    ### here if you plan to use paprefs)
    #load-module module-esound-protocol-tcp
    load-module module-native-protocol-tcp
    load-module module-zeroconf-publish
    ### Load the RTP reciever module (also configured via paprefs, see above)
    load-module module-rtp-recv
    ### Load the RTP sender module (also configured via paprefs, see above)
    #load-module module-null-sink sink_name=rtp format=s16be channels=2 rate=44100 description="RTP Multicast Sink"
    #load-module module-rtp-send source=rtp.monitor
    ### Load additional modules from GConf settings. This can be configured with the paprefs tool.
    ### Please keep in mind that the modules configured by paprefs might conflict with manually
    ### loaded modules.
    .ifexists module-gconf.so
    .nofail
    load-module module-gconf
    .fail
    .endif
    ### Automatically restore the default sink/source when changed by the user during runtime
    load-module module-default-device-restore
    ### Automatically move streams to the default sink if the sink they are
    ### connected to dies, similar for sources
    load-module module-rescue-streams
    ### Make sure we always have a sink around, even if it is a null sink.
    load-module module-always-sink
    ### Honour intended role device property
    load-module module-intended-roles
    ### Automatically suspend sinks/sources that become idle for too long
    load-module module-suspend-on-idle
    ### If autoexit on idle is enabled we want to make sure we only quit
    ### when no local session needs us anymore.
    load-module module-console-kit
    ### Enable positioned event sounds
    load-module module-position-event-sounds
    ### Cork music streams when a phone stream is active
    load-module module-cork-music-on-phone
    # X11 modules should not be started from default.pa so that one daemon
    # can be shared by multiple sessions.
    ### Load X11 bell module
    #load-module module-x11-bell sample=bell-windowing-system
    ### Register ourselves in the X11 session manager
    #load-module module-x11-xsmp
    ### Publish connection data in the X11 root window
    #.ifexists module-x11-publish.so
    #.nofail
    #load-module module-x11-publish
    #.fail
    #.endif
    ### Make some devices default
    #set-default-sink output
    #set-default-source input
    please tell me what else should I post. Also, is it necessary to have the cookie synced over network (nfs, sshfs etc...) or is it OK if I just copy it?

  • Urgent help:send image over network using rmi

    hi all,
    i have few question about send image using rmi.
    1) should i use ByteArrayOutputStream to convert image into byte array before i send over network or just use fileinputstream to convert image into byte array like what i have done as below?
    public class RemoteServerImpl  extends UnicastRemoteObject implements RemoteServer
      public RemoteServerImpl() throws RemoteException
      public byte[] getimage() throws RemoteException
        try{
           // capture the whole screen
           BufferedImage screencapture = new Robot().createScreenCapture(new     Rectangle(Toolkit.getDefaultToolkit().getScreenSize()) );
           // Save as JPEG
           File file = new File("screencapture.jpg");
           ImageIO.write(screencapture, "jpg", file);
            byte[] fileByteContent = null;
           fileByteContent = getImageStream("screencapture.jpg");
           return fileByteContent;
        catch(IOException ex)
      public byte[] getImageStream(String fname) // local method
        String fileName = fname;
        FileInputStream fileInputStream = null;
        byte[] fileByteContent = null;
          try
            int count = 0;
            fileInputStream = new FileInputStream(fileName);  // Obtains input bytes from a file.
            fileByteContent = new byte[fileInputStream.available()]; // Assign size to byte array.
            while (fileInputStream.available()>0)   // Correcting file content bytes, and put them into the byte array.
               fileByteContent[count]=(byte)fileInputStream.read();
               count++;
           catch (IOException fnfe)
         return fileByteContent;           
    }2)if what i done is wrong,can somebody give me guide?else if correct ,then how can i rebuild the image from the byte array and put it in a JLable?i now must use FileOuputStream but how?can anyone answer me or simple code?
    thanks in advance..

    Hi! well a had the same problem sending an image trough RMI.. To solve this i just read the image file into a byte Array and send the array to the client, and then the client creates an imegeIcon from the byte Array containing the image.. Below is the example function ton read the file to a byte Array (on the server) and the function to convert it to a an imageIcon (on the client).
    //      Returns the contents of the file in a byte array.
        public static byte[] getBytesFromFile(File file) throws IOException {
            InputStream is = new FileInputStream(file);
            // Get the size of the file
            long length = file.length();
            // You cannot create an array using a long type.
            // It needs to be an int type.
            // Before converting to an int type, check
            // to ensure that file is not larger than Integer.MAX_VALUE.
            if (length > Integer.MAX_VALUE) {
                // File is too large
            // Create the byte array to hold the data
            byte[] bytes = new byte[(int)length];
            // Read in the bytes
            int offset = 0;
            int numRead = 0;
            while (offset < bytes.length
                   && (numRead=is.read(bytes, offset, bytes.length-offset)) >= 0) {
                offset += numRead;
            // Ensure all the bytes have been read in
            if (offset < bytes.length) {
                throw new IOException("Could not completely read file "+file.getName());
            // Close the input stream and return bytes
            is.close();
            return bytes;
        }to use this function simply use something like this
    public byte[] getImage(){
    byte[] imageData;
              File file = new File("pic.jpg");
              // Change pic.jpg for the name of your file (duh)
              try{
                   imageData = getBytesFromFile(file);
                   // Send to client via RMI
                            return imageData;
              }catch(IOException ioe){
                           // Handle exception
                           return null; // or whatever you want..
    }and then on the client you could call a function like this
    public ImageIcon getImageFromServer(){
         try{
              // get the image from the RMI server
              byte[] imgBytes = myServerObject.getImage();
              // Create an imageIcon from the Array of bytes
              ImageIcon ii = new ImageIcon(imgBytes);
              return ii;
         }catch(Exception e){
              // Handle some error..
              // If yo get here probably something went wrong with the server
              // like File Not Found or something like that..
              e.printStackTrace();
              return null;
    }Hope it helps you..

  • Running a java program over network

    Hi,
    How a java program on a machine can be run without having JRE on the same machine, rather interpreting bytecode over network having JRE on another machine?

    Rahul.Kumar wrote:
    well, so my java program is running on x. Initialy X had JRE and on invoking java program from command prompt, it had looked for JRE at path, set in environmental settings. Now I moved JRE to another machine Y and connected these two machines (X and Y). You have two machines X and Y.
    "Connected" or not has nothing to do with this discussion.
    In X path is set to the JRE on Y. The path on X has absolutely nothing to do with anything on Y.
    Now execute java program on X, theoretically it should work or what is wrong with this?This makes no sense. Presuming you meant Y in the above then the following must be true.
    1. You must have a JRE on Y.
    2. You must have a java application on Y (or one accessible via the file system on Y.)
    3. You must be on Y and start the JRE passing the java application that is on Y to it.
    Notice in the above there is no mention of X. There can be no mention of X.

  • Accessing shared files over network

    I am having some problems with a couple of database files that I access with a Java program over network. Different computers running this program all need access to these files, and my question is if anyone know of a good way to make sure that only one user have access to these files at the time. There is no server software running were the files are stored, they are simply reached through file sharing. Currently I am creating a lock file indicating that someone is editing the files, however if I am unlucky 2 users create that lockfile at the same time and then both get access to the file corrupting it. Anyone experienced this and know of a nice solution to avoid it?

    I am having some problems with a couple of database
    files that I access with a Java program over network.
    Different computers running this program all need
    access to these files, and my question is if anyone
    know of a good way to make sure that only one user
    have access to these files at the time.Use a database server instead.

  • Share Aperture photos over network

    Hallo every body,
    iam searching for a solution, how to share photo over network for a long time, in our company we have 40 macs(imac, mac bookpro) and 3 xserve, vtrak and 30pc. and we have round about 30000 pic they are saved in iphoto library on one of the xserve.
    My Boss wants from me to find a solution to share these photos over network. the mac users must use iphoto to access these photos.
    which program shall i install on the server so that the client users can access the photos from there macs through iphoto.
    at the beginning i used the share library option in iphoto, until iphoto 9.1.1. By iphoto 9.1.1 on the client when i click on the shared library my searching field disappears and i cant search in the shared photos.
    I thought Aperture is the solution, so i shared the aperture library over the network (with afp protocoll) but in order to access the network aperture library, first i need to install aperture on the client and then i open iphoto and from iphoto option i can choose the option access aperture library.
    how can i solve it without to install aperture on the client, is there any iphoto plugin so that i can access aperture library without installing aperture
    or is there somebody uses another solution???
    please help
    best regards
    Tony

    Neither iPhoto nor Aperture is the solution for this.
    The idea of using iphoto on the client machines is wrong, it's just not designed for that use. Iphoto is designed for a family with a point and shoot camera, or even a phone. Aperture is a pro level photomanager. Installing Aperture on all the mchines means you will have to purchase the app for all the machine, you need a site licence.
    Also, it won't work anyway. You can't share an Aperture Library like an iPhoto one an only one user can access the Library at a time. So, one of the users acesses the Library and all the others are locked out.
    Neither are what you need: you need a media server application. A pro level media server. Tell your boss he's fooling himself if he thinks anything else will work reliably.
    Regards
    TD

  • Slow streaming over wifi using ipad

    Why is streaming over wifi slower than over cellular connection?  Other devices don't have the same issue.

    generally we all think and expect wifi will be faster than a cell connection.  But that will not always be the case.  A good uncongested LTE runs pretty fast.
    But the wifi should be fast enough that you wouldn't notice any issues unless:
    You are using a public wifi spot where the signal is metered.  Where I work, they clamp the wifi for guests at 250k.
    The wifi cannot run any faster than your internet connection.  Is it clean?
    Recent stoires here are explaining how verizon and Comcast have been allowing you tube and netflix feeds to become overcongested, in an effort to extract $$ from them for the privilange of sending you the signal.
    a good place to start is to get a speed app - like Speed test (there are a bunch in the store) and see what speed your wifi is delivering.
    One thing that is almost certain, your wifi is a whole lot cheaper than your cell signal!

  • Install Solaris10 over network.

    I have one sinfire v245 box which is in remote location (DR site). I want to install Solari10-u5 on it.
    I can't travel to remote site due to some restriction.
    Presently Solaris10-U1 is installed in the box.
    I have telnet/SSH access to Solaris-OS, and i have SSH access to it's "Advanced Lights Out Manager".
    There is no one in remote location who can insert Solaris10-u5 media.
    In this situation, is there anyway that i can freshly install Solaris10-u5 on it ?

    Ok. I learned the way how to install Solaris over network.
    I have created a install server on another solaris box, the client and this box are in the same network.
    I am trying to install the client, i am getting this error on the client continuously . Any idea how to solve this ?
    ar_entry_query: Could not find the ace for source address <IP_Address>
    ar_entry_query: Could not find the ace for source address <IP_Address>

  • HTTP 1.1: Using streams over socket; How ?

    Can anyone give me a short example as how to handle streams over a persistent socket-connection ?
    I've trouble handling this.
    I can't "reget" the stream (create a new input/output stream over an existing socket-connection).
    Is there someone who can help me ?
    I'm getting confused !!!

    Since no one helped I could only try to find out myself:
    The problem is I used some example-source that fitted well for HTTP 1.0, but led to erroneous results when applied to HTTP 1.1
    It's no problem in HTTP 1.1, but you need to read ALL input (headers and possibly content) before trying to process anything:
    From the headers you need to read until an empty line is discovered.... Don't just break on return or newline, this will leave an extra character in the input:
    Protocol requires both \r and \n. So you always break 1 char to early when scanning bytes and then concluding on a \r that the line is over.
    Then you should possibly read 'contentlength bytes' (I've not tried it out yet) in case of POST.
    Flushing is enough to write all data to output.
    Open and close can't work. "Regetting" a stream is not possible, so all input for this request must be taken from inputstream before trying to process the next request.

  • Expdp over network fails.

    I have a test1 and test2 db's on two different servers. I want to run expdp from test2 db and get the export of a table from test1. I have created a db link and used network_link in expdp command. Granted read,write on directory to user with which i am connecting to db.
    Using expdp over a network_link fails with this error. For the same user I have tried it locally on test2 db and it works fine.
    Is there any other step to be done ?
    ORA-39002: invalid operation
    ORA-39070: Unable to open the log file.
    ORA-39087: directory name DUMPS is invalid

    expdp un/pwd*@test1db* job_name=EXP_test1 directory=dumps network_link=test1.dummy.COM dumpfile=dp.dmp log
    file=dp.LOG tables=a.tableThis is the problem. When running export using NETWORK_LINK to test1, you need to connect to test2 not test1.
    The idea is your connect to test2 first , test2 then connect to test1 using database link and bring the data over network and dump to local directory.
    In your command it's actually running export against test1, then in that case, test1 need to have directory called dumps defined.

Maybe you are looking for

  • IPod Touch Strangeness: Battery life and iPhoto

    I have a first generation iPod Touch (8 GB), running v.2.1. I recently went on a long trip, and the iPod Touch worked as expected, with pretty long battery life, etc. However, on my return, I've noticed two oddities. First, now whenever I attach my i

  • Unacceptable levels of service

    What is going on with BT?, for weeks now I have experienced connection issues along with many others it seems by reading these forums.  I have tried everything possible with my hardware/PC and yet the problem persists, this is not an issue my end.  H

  • Why does Microsoft continue to ignore web standards in Outlook?

    Why does Microsoft refuse to support CSS development? Is there an email client available that supports full CSS and HTML rendering? I know about Entourage, but that is for Mac and we use PC at work. I am really interested in email newsletters and dev

  • How to load balance serving MP4 files via AMS

    Hey gurus, We have one centralized storage server that stores videos, Lets call this Server A, we have 4 more servers that we want to use to load the files from Server A to load balance and location balance the loading of files. Servers B-E are on a

  • One Publishing "Unknown Error" Problem Fixed

    Found a solution to one of the problems I was having publishing to a folder. Kept getting the unknown error when trying to publish and, after a little digging, found it to be a problem with iWeb's cache files. Trying to delete them manually just upse