001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 * 019 */ 020package org.apache.mina.transport.socket; 021 022import java.net.InetSocketAddress; 023import java.net.ServerSocket; 024import java.util.Set; 025 026import org.apache.mina.core.service.IoAcceptor; 027 028/** 029 * {@link IoAcceptor} for socket transport (TCP/IP). This class 030 * handles incoming TCP/IP based socket connections. 031 * 032 * @author <a href="http://mina.apache.org">Apache MINA Project</a> 033 */ 034public interface SocketAcceptor extends IoAcceptor { 035 /** 036 * @return the local InetSocketAddress which is bound currently. If more than one 037 * address are bound, only one of them will be returned, but it's not 038 * necessarily the firstly bound address. 039 * This method overrides the {@link IoAcceptor#getLocalAddress()} method. 040 */ 041 InetSocketAddress getLocalAddress(); 042 043 /** 044 * @return a {@link Set} of the local InetSocketAddress which are bound currently. 045 * This method overrides the {@link IoAcceptor#getDefaultLocalAddress()} method. 046 */ 047 InetSocketAddress getDefaultLocalAddress(); 048 049 /** 050 * Sets the default local InetSocketAddress to bind when no argument is specified in 051 * {@link #bind()} method. Please note that the default will not be used 052 * if any local InetSocketAddress is specified. 053 * This method overrides the {@link IoAcceptor#setDefaultLocalAddress(java.net.SocketAddress)} method. 054 * 055 * @param localAddress The local address 056 */ 057 void setDefaultLocalAddress(InetSocketAddress localAddress); 058 059 /** 060 * @see ServerSocket#getReuseAddress() 061 * 062 * @return <tt>true</tt> if the <tt>SO_REUSEADDR</tt> is enabled 063 */ 064 boolean isReuseAddress(); 065 066 /** 067 * @see ServerSocket#setReuseAddress(boolean) 068 * 069 * @param reuseAddress tells if the <tt>SO_REUSEADDR</tt> is to be enabled 070 */ 071 void setReuseAddress(boolean reuseAddress); 072 073 /** 074 * @return the size of the backlog. 075 */ 076 int getBacklog(); 077 078 /** 079 * Sets the size of the backlog. This can only be done when this 080 * class is not bound 081 * 082 * @param backlog The backlog's size 083 */ 084 void setBacklog(int backlog); 085 086 /** 087 * @return the default configuration of the new SocketSessions created by 088 * this acceptor service. 089 */ 090 SocketSessionConfig getSessionConfig(); 091}