Rev 30 | Blame | Compare with Previous | Last modification | View Log | RSS feed
(*Licensed to the Apache Software Foundation (ASF) under oneor more contributor license agreements. See the NOTICE filedistributed with this work for additional informationregarding copyright ownership. The ASF licenses this fileto you under the Apache License, Version 2.0 (the"License"); you may not use this file except in compliancewith the License. You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing,software distributed under the License is distributed on an"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANYKIND, either express or implied. See the License for thespecific language governing permissions and limitationsunder the License.*)open Thriftclass t port =objectinherit Transport.server_tval mutable sock = Nonemethod listen =let s = Unix.socket Unix.PF_INET Unix.SOCK_STREAM 0 insock <- Some s;Unix.bind s (Unix.ADDR_INET (Unix.inet_addr_any, port));Unix.listen s 256method close =match sock withSome s -> Unix.shutdown s Unix.SHUTDOWN_ALL; Unix.close s;sock <- None| _ -> ()method acceptImpl =match sock withSome s -> let (fd,_) = Unix.accept s innew TChannelTransport.t (Unix.in_channel_of_descr fd,Unix.out_channel_of_descr fd)| _ -> raise (Transport.E (Transport.NOT_OPEN,"TServerSocket: Not listening but tried to accept"))end