AFSocketType.java

  1. /*
  2.  * junixsocket
  3.  *
  4.  * Copyright 2009-2024 Christian Kohlschütter
  5.  *
  6.  * Licensed under the Apache License, Version 2.0 (the "License");
  7.  * you may not use this file except in compliance with the License.
  8.  * You may obtain a copy of the License at
  9.  *
  10.  *     http://www.apache.org/licenses/LICENSE-2.0
  11.  *
  12.  * Unless required by applicable law or agreed to in writing, software
  13.  * distributed under the License is distributed on an "AS IS" BASIS,
  14.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15.  * See the License for the specific language governing permissions and
  16.  * limitations under the License.
  17.  */
  18. package org.newsclub.net.unix;

  19. /**
  20.  * Describes the "type" of a socket.
  21.  *
  22.  * @author Christian Kohlschütter
  23.  */
  24. public enum AFSocketType {
  25.   /**
  26.    * Stream-oriented socket.
  27.    */
  28.   SOCK_STREAM(NativeUnixSocket.SOCK_STREAM), //

  29.   /**
  30.    * Datagram-oriented socket. Usually permitting data loss (but not with {@link AFUNIXSocket}).
  31.    */
  32.   SOCK_DGRAM(NativeUnixSocket.SOCK_DGRAM), //

  33.   /**
  34.    * Raw mode.
  35.    */
  36.   SOCK_RAW(NativeUnixSocket.SOCK_RAW), //

  37.   /**
  38.    * Reliably-delivered datagram messages.
  39.    *
  40.    * Used by {@code AFTIPCDatagramSocket} to differentiate between datagram connects that may or may
  41.    * not permit package loss.
  42.    */
  43.   SOCK_RDM(NativeUnixSocket.SOCK_RDM), //

  44.   /**
  45.    * Sequential packet socket.
  46.    */
  47.   SOCK_SEQPACKET(NativeUnixSocket.SOCK_SEQPACKET), //
  48.   ;

  49.   private final int id;

  50.   AFSocketType(int id) {
  51.     this.id = id;
  52.   }

  53.   int getId() {
  54.     return id;
  55.   }
  56. }