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.DatagramSocket;
023import java.net.PortUnreachableException;
024
025import org.apache.mina.core.session.IoSessionConfig;
026
027/**
028 * An {@link IoSessionConfig} for datagram transport type.
029 *
030 * @author <a href="http://mina.apache.org">Apache MINA Project</a>
031 */
032public interface DatagramSessionConfig extends IoSessionConfig {
033    /**
034     * @see DatagramSocket#getBroadcast()
035     * 
036     * @return <tt>true</tt> if SO_BROADCAST is enabled.
037     */
038    boolean isBroadcast();
039
040    /**
041     * @see DatagramSocket#setBroadcast(boolean)
042     * 
043     * @param broadcast Tells if SO_BROACAST is enabled or not 
044     */
045    void setBroadcast(boolean broadcast);
046
047    /**
048     * @see DatagramSocket#getReuseAddress()
049     * 
050     * @return <tt>true</tt> if SO_REUSEADDR is enabled.
051     */
052    boolean isReuseAddress();
053
054    /**
055     * @see DatagramSocket#setReuseAddress(boolean)
056     * 
057     * @param reuseAddress Tells if SO_REUSEADDR is enabled or disabled
058     */
059    void setReuseAddress(boolean reuseAddress);
060
061    /**
062     * @see DatagramSocket#getReceiveBufferSize()
063     * 
064     * @return the size of the receive buffer
065     */
066    int getReceiveBufferSize();
067
068    /**
069     * @see DatagramSocket#setReceiveBufferSize(int)
070     * 
071     * @param receiveBufferSize The size of the receive buffer
072     */
073    void setReceiveBufferSize(int receiveBufferSize);
074
075    /**
076     * @see DatagramSocket#getSendBufferSize()
077     * 
078     * @return the size of the send buffer
079     */
080    int getSendBufferSize();
081
082    /**
083     * @see DatagramSocket#setSendBufferSize(int)
084     * 
085     * @param sendBufferSize The size of the send buffer
086     */
087    void setSendBufferSize(int sendBufferSize);
088
089    /**
090     * @see DatagramSocket#getTrafficClass()
091     * 
092     * @return the traffic class
093     */
094    int getTrafficClass();
095
096    /**
097     * @see DatagramSocket#setTrafficClass(int)
098     * 
099     * @param trafficClass The traffic class to set, one of IPTOS_LOWCOST (0x02)
100     * IPTOS_RELIABILITY (0x04), IPTOS_THROUGHPUT (0x08) or IPTOS_LOWDELAY (0x10)
101     */
102    void setTrafficClass(int trafficClass);
103
104    /**
105     * If method returns true, it means session should be closed when a
106     * {@link PortUnreachableException} occurs.
107     * 
108     * @return Tells if we should close if the port is unreachable
109     */
110    boolean isCloseOnPortUnreachable();
111
112    /**
113     * Sets if the session should be closed if an {@link PortUnreachableException} 
114     * occurs.
115     * 
116     * @param closeOnPortUnreachable <tt>true</tt> if we should close if the port is unreachable
117     */
118    void setCloseOnPortUnreachable(boolean closeOnPortUnreachable);
119}