Changeset 442

Show
Ignore:
Timestamp:
07/19/07 10:04:12 (1 year ago)
Author:
blackhedd
Message:

stop tcp server

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • version_0/java/src/com/rubyeventmachine/EM.java

    r438 r442  
    5050        private TreeMap<Long, String> Timers; 
    5151        private TreeMap<String, EventableChannel> Connections; 
     52        private TreeMap<String, ServerSocketChannel> Acceptors; 
     53 
    5254        private boolean bRunReactor; 
    5355        private long BindingIndex; 
     
    6062                Timers = new TreeMap<Long, String>(); 
    6163                Connections = new TreeMap<String, EventableChannel>(); 
     64                Acceptors = new TreeMap<String, ServerSocketChannel>(); 
     65                 
    6266                BindingIndex = 100000; 
    6367                EmptyByteBuffer = ByteBuffer.allocate(0); 
     
    223227                server.socket().bind(new java.net.InetSocketAddress(address, port)); 
    224228                String s = createBinding(); 
     229                Acceptors.put(s, server); 
    225230                server.register(mySelector, SelectionKey.OP_ACCEPT, s); 
    226231                return s; 
    227232        } 
    228233 
     234        public void stopTcpServer (String signature) throws IOException { 
     235                ServerSocketChannel server = Acceptors.remove(signature); 
     236                if (server != null) 
     237                        server.close(); 
     238                else 
     239                        throw new RuntimeException ("failed to close unknown acceptor"); 
     240        } 
     241         
    229242        public void sendData (String sig, String data, int length) throws IOException { 
    230243                (Connections.get(sig)).scheduleOutboundData( ByteBuffer.wrap(data.getBytes())); 
  • version_0/lib/jeventmachine.rb

    r441 r442  
    6666                @em.startTcpServer server, port 
    6767        end 
     68        def self.stop_tcp_server sig 
     69                @em.stopTcpServer sig 
     70        end 
    6871        def self.send_data sig, data, length 
    6972                @em.sendData sig, data, length