View Javadoc
1   /*
2    * Copyright (C) 2013 4th Line GmbH, Switzerland
3    *
4    * The contents of this file are subject to the terms of either the GNU
5    * Lesser General Public License Version 2 or later ("LGPL") or the
6    * Common Development and Distribution License Version 1 or later
7    * ("CDDL") (collectively, the "License"). You may not use this file
8    * except in compliance with the License. See LICENSE.txt for more
9    * information.
10   *
11   * This program is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14   */
15  
16  package org.fourthline.cling.transport.impl;
17  
18  import org.fourthline.cling.transport.spi.MulticastReceiverConfiguration;
19  
20  import java.net.InetAddress;
21  import java.net.UnknownHostException;
22  
23  /**
24   * Settings for the default implementation.
25   * 
26   * @author Christian Bauer
27   */
28  public class MulticastReceiverConfigurationImpl implements MulticastReceiverConfiguration {
29  
30      private InetAddress group;
31      private int port;
32      private int maxDatagramBytes;
33  
34      public MulticastReceiverConfigurationImpl(InetAddress group, int port, int maxDatagramBytes) {
35          this.group = group;
36          this.port = port;
37          this.maxDatagramBytes = maxDatagramBytes;
38      }
39  
40      /**
41       * Defaults to maximum datagram size of 640 bytes (512 per UDA 1.0, 128 byte header).
42       */
43      public MulticastReceiverConfigurationImpl(InetAddress group, int port) {
44          this(group, port, 640);
45      }
46  
47      public MulticastReceiverConfigurationImpl(String group, int port, int maxDatagramBytes) throws UnknownHostException {
48          this(InetAddress.getByName(group), port, maxDatagramBytes);
49      }
50  
51      /**
52       * Defaults to maximum datagram size of 640 bytes (512 per UDA 1.0, 128 byte header).
53       */
54      public MulticastReceiverConfigurationImpl(String group, int port) throws UnknownHostException {
55          this(InetAddress.getByName(group), port, 640);
56      }
57  
58      public InetAddress getGroup() {
59          return group;
60      }
61  
62      public void setGroup(InetAddress group) {
63          this.group = group;
64      }
65  
66      public int getPort() {
67          return port;
68      }
69  
70      public void setPort(int port) {
71          this.port = port;
72      }
73  
74      public int getMaxDatagramBytes() {
75          return maxDatagramBytes;
76      }
77  
78      public void setMaxDatagramBytes(int maxDatagramBytes) {
79          this.maxDatagramBytes = maxDatagramBytes;
80      }
81  
82  }