code: protected synchronized void create(boolean stream) throws IOException {
          this.stream = stream;
  
          if (!stream) {
              ResourceManager.beforeUdpCreate();
              try {
                  socketCreate(false);
              } catch (IOException ioe) {
                  ResourceManager.afterUdpClose();
                  throw ioe;
              }
          } else {
              socketCreate(true);
          }
          if (socket != null)
              socket.setCreated();
          if (serverSocket != null)
              serverSocket.setCreated();
  
          // socketCreate will set |fd| if it succeeds.
          if (fd != null && fd.valid()) {
              guard.open("close");
          }
      }
docs: Creates a socket with a boolean that specifies whether this
  is a stream socket (true) or an unconnected UDP socket (false).