Why don't I see output on the client?

matt p matt at scanner911app.com
Mon Dec 21 15:09:07 EST 2009


Hello --

  I'm writing a simple server which will rebroadcast an audio stream to N
clients.

  Here is my code:

        
        Channel channel = channelStateEvent.getChannel();
        try {
            URL url = new URL("http://audio2.radioreference.com/ca_lapd1");
            URLConnection conn = url.openConnection();
            InputStream inputStream = conn.getInputStream();

            ChannelBuffer buffer = ChannelBuffers.buffer(256);
//            ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
//            ChannelBufferOutputStream outputStream = new
ChannelBufferOutputStream(buffer);

            int result;
            byte readbuffer[] = new byte[256];

            while ((result = inputStream.read(readbuffer)) != -1 ) {

                buffer.writeBytes(readbuffer);
                channel.write(buffer);
                buffer.clear();
//                System.out.println("writing "+ result + " bytes");
            }

        } catch (MalformedURLException e) {
            e.printStackTrace();  //To change body of catch statement use
File | Settings | File Templates.
        } catch (IOException e) {
            e.printStackTrace();  //To change body of catch statement use
File | Settings | File Templates.
        }


Scanner server is from the example:

public class ScannerServer {

    public static void main(String[] args) {
        ChannelFactory factory = new NioServerSocketChannelFactory(
                Executors.newCachedThreadPool(),
                Executors.newCachedThreadPool()
        );

        ServerBootstrap bootstrap = new ServerBootstrap(factory);


        ScannerServerHandler handler = new ScannerServerHandler();

        ChannelPipeline pipeline = bootstrap.getPipeline();
        pipeline.addLast("handler", handler);
        bootstrap.setOption("child.tcpNoDelay", true);
        bootstrap.setOption("child.keepAlive", true);
        bootstrap.bind(new InetSocketAddress(8888));
    }


-- 
View this message in context: http://n2.nabble.com/Why-don-t-I-see-output-on-the-client-tp4200304p4200304.html
Sent from the Netty User Group mailing list archive at Nabble.com.


More information about the netty-users mailing list