java.net.ServerSocket.checkOpen()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(6.9k)|赞(0)|评价(0)|浏览(126)

本文整理了Java中java.net.ServerSocket.checkOpen()方法的一些代码示例,展示了ServerSocket.checkOpen()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ServerSocket.checkOpen()方法的具体详情如下:
包路径:java.net.ServerSocket
类名称:ServerSocket
方法名:checkOpen

ServerSocket.checkOpen介绍

暂无

代码示例

代码示例来源:origin: robovm/robovm

  1. /**
  2. * Gets the socket {@link SocketOptions#SO_TIMEOUT accept timeout}.
  3. *
  4. * @throws IOException
  5. * if the option cannot be retrieved.
  6. */
  7. public synchronized int getSoTimeout() throws IOException {
  8. checkOpen();
  9. return ((Integer) impl.getOption(SocketOptions.SO_TIMEOUT)).intValue();
  10. }

代码示例来源:origin: robovm/robovm

  1. /**
  2. * Gets the value of the socket option {@code SocketOptions.SO_REUSEADDR}.
  3. *
  4. * @return {@code true} if the option is enabled, {@code false} otherwise.
  5. * @throws SocketException
  6. * if an error occurs while reading the option value.
  7. */
  8. public boolean getReuseAddress() throws SocketException {
  9. checkOpen();
  10. return ((Boolean) impl.getOption(SocketOptions.SO_REUSEADDR)).booleanValue();
  11. }

代码示例来源:origin: robovm/robovm

  1. /**
  2. * Sets this socket's {@link SocketOptions#SO_SNDBUF receive buffer size}.
  3. */
  4. public void setReceiveBufferSize(int size) throws SocketException {
  5. checkOpen();
  6. if (size < 1) {
  7. throw new IllegalArgumentException("size < 1");
  8. }
  9. impl.setOption(SocketOptions.SO_RCVBUF, Integer.valueOf(size));
  10. }

代码示例来源:origin: robovm/robovm

  1. /**
  2. * Sets the value for the socket option {@code SocketOptions.SO_REUSEADDR}.
  3. *
  4. * @param reuse
  5. * the socket option setting.
  6. * @throws SocketException
  7. * if an error occurs while setting the option value.
  8. */
  9. public void setReuseAddress(boolean reuse) throws SocketException {
  10. checkOpen();
  11. impl.setOption(SocketOptions.SO_REUSEADDR, Boolean.valueOf(reuse));
  12. }

代码示例来源:origin: robovm/robovm

  1. /**
  2. * Returns this socket's {@link SocketOptions#SO_RCVBUF receive buffer size}.
  3. */
  4. public int getReceiveBufferSize() throws SocketException {
  5. checkOpen();
  6. return ((Integer) impl.getOption(SocketOptions.SO_RCVBUF)).intValue();
  7. }

代码示例来源:origin: robovm/robovm

  1. /**
  2. * Sets the {@link SocketOptions#SO_TIMEOUT accept timeout} in milliseconds for this socket.
  3. * This accept timeout defines the period the socket will block waiting to
  4. * accept a connection before throwing an {@code InterruptedIOException}. The value
  5. * {@code 0} (default) is used to set an infinite timeout. To have effect
  6. * this option must be set before the blocking method was called.
  7. *
  8. * @param timeout the timeout in milliseconds or 0 for no timeout.
  9. * @throws SocketException
  10. * if an error occurs while setting the option.
  11. */
  12. public synchronized void setSoTimeout(int timeout) throws SocketException {
  13. checkOpen();
  14. if (timeout < 0) {
  15. throw new IllegalArgumentException("timeout < 0");
  16. }
  17. impl.setOption(SocketOptions.SO_TIMEOUT, Integer.valueOf(timeout));
  18. }

代码示例来源:origin: robovm/robovm

  1. /**
  2. * Waits for an incoming request and blocks until the connection is opened.
  3. * This method returns a socket object representing the just opened
  4. * connection.
  5. *
  6. * @return the connection representing socket.
  7. * @throws IOException
  8. * if an error occurs while accepting a new connection.
  9. */
  10. public Socket accept() throws IOException {
  11. checkOpen();
  12. if (!isBound()) {
  13. throw new SocketException("Socket is not bound");
  14. }
  15. Socket aSocket = new Socket();
  16. try {
  17. implAccept(aSocket);
  18. } catch (IOException e) {
  19. aSocket.close();
  20. throw e;
  21. }
  22. return aSocket;
  23. }

代码示例来源:origin: robovm/robovm

  1. checkOpen();
  2. if (isBound()) {
  3. throw new BindException("Socket is already bound");

代码示例来源:origin: com.mobidevelop.robovm/robovm-rt

  1. /**
  2. * Sets the value for the socket option {@code SocketOptions.SO_REUSEADDR}.
  3. *
  4. * @param reuse
  5. * the socket option setting.
  6. * @throws SocketException
  7. * if an error occurs while setting the option value.
  8. */
  9. public void setReuseAddress(boolean reuse) throws SocketException {
  10. checkOpen();
  11. impl.setOption(SocketOptions.SO_REUSEADDR, Boolean.valueOf(reuse));
  12. }

代码示例来源:origin: com.bugvm/bugvm-rt

  1. /**
  2. * Gets the socket {@link SocketOptions#SO_TIMEOUT accept timeout}.
  3. *
  4. * @throws IOException
  5. * if the option cannot be retrieved.
  6. */
  7. public synchronized int getSoTimeout() throws IOException {
  8. checkOpen();
  9. return ((Integer) impl.getOption(SocketOptions.SO_TIMEOUT)).intValue();
  10. }

代码示例来源:origin: MobiVM/robovm

  1. /**
  2. * Sets this socket's {@link SocketOptions#SO_SNDBUF receive buffer size}.
  3. */
  4. public void setReceiveBufferSize(int size) throws SocketException {
  5. checkOpen();
  6. if (size < 1) {
  7. throw new IllegalArgumentException("size < 1");
  8. }
  9. impl.setOption(SocketOptions.SO_RCVBUF, Integer.valueOf(size));
  10. }

代码示例来源:origin: MobiVM/robovm

  1. /**
  2. * Returns this socket's {@link SocketOptions#SO_RCVBUF receive buffer size}.
  3. */
  4. public int getReceiveBufferSize() throws SocketException {
  5. checkOpen();
  6. return ((Integer) impl.getOption(SocketOptions.SO_RCVBUF)).intValue();
  7. }

代码示例来源:origin: ibinti/bugvm

  1. /**
  2. * Sets the value for the socket option {@code SocketOptions.SO_REUSEADDR}.
  3. *
  4. * @param reuse
  5. * the socket option setting.
  6. * @throws SocketException
  7. * if an error occurs while setting the option value.
  8. */
  9. public void setReuseAddress(boolean reuse) throws SocketException {
  10. checkOpen();
  11. impl.setOption(SocketOptions.SO_REUSEADDR, Boolean.valueOf(reuse));
  12. }

代码示例来源:origin: FlexoVM/flexovm

  1. /**
  2. * Gets the value of the socket option {@code SocketOptions.SO_REUSEADDR}.
  3. *
  4. * @return {@code true} if the option is enabled, {@code false} otherwise.
  5. * @throws SocketException
  6. * if an error occurs while reading the option value.
  7. */
  8. public boolean getReuseAddress() throws SocketException {
  9. checkOpen();
  10. return ((Boolean) impl.getOption(SocketOptions.SO_REUSEADDR)).booleanValue();
  11. }

代码示例来源:origin: com.bugvm/bugvm-rt

  1. /**
  2. * Sets the value for the socket option {@code SocketOptions.SO_REUSEADDR}.
  3. *
  4. * @param reuse
  5. * the socket option setting.
  6. * @throws SocketException
  7. * if an error occurs while setting the option value.
  8. */
  9. public void setReuseAddress(boolean reuse) throws SocketException {
  10. checkOpen();
  11. impl.setOption(SocketOptions.SO_REUSEADDR, Boolean.valueOf(reuse));
  12. }

代码示例来源:origin: com.bugvm/bugvm-rt

  1. /**
  2. * Gets the value of the socket option {@code SocketOptions.SO_REUSEADDR}.
  3. *
  4. * @return {@code true} if the option is enabled, {@code false} otherwise.
  5. * @throws SocketException
  6. * if an error occurs while reading the option value.
  7. */
  8. public boolean getReuseAddress() throws SocketException {
  9. checkOpen();
  10. return ((Boolean) impl.getOption(SocketOptions.SO_REUSEADDR)).booleanValue();
  11. }

代码示例来源:origin: ibinti/bugvm

  1. /**
  2. * Returns this socket's {@link SocketOptions#SO_RCVBUF receive buffer size}.
  3. */
  4. public int getReceiveBufferSize() throws SocketException {
  5. checkOpen();
  6. return ((Integer) impl.getOption(SocketOptions.SO_RCVBUF)).intValue();
  7. }

代码示例来源:origin: com.gluonhq/robovm-rt

  1. /**
  2. * Returns this socket's {@link SocketOptions#SO_RCVBUF receive buffer size}.
  3. */
  4. public int getReceiveBufferSize() throws SocketException {
  5. checkOpen();
  6. return ((Integer) impl.getOption(SocketOptions.SO_RCVBUF)).intValue();
  7. }

代码示例来源:origin: MobiVM/robovm

  1. /**
  2. * Sets the value for the socket option {@code SocketOptions.SO_REUSEADDR}.
  3. *
  4. * @param reuse
  5. * the socket option setting.
  6. * @throws SocketException
  7. * if an error occurs while setting the option value.
  8. */
  9. public void setReuseAddress(boolean reuse) throws SocketException {
  10. checkOpen();
  11. impl.setOption(SocketOptions.SO_REUSEADDR, Boolean.valueOf(reuse));
  12. }

代码示例来源:origin: ibinti/bugvm

  1. /**
  2. * Gets the value of the socket option {@code SocketOptions.SO_REUSEADDR}.
  3. *
  4. * @return {@code true} if the option is enabled, {@code false} otherwise.
  5. * @throws SocketException
  6. * if an error occurs while reading the option value.
  7. */
  8. public boolean getReuseAddress() throws SocketException {
  9. checkOpen();
  10. return ((Boolean) impl.getOption(SocketOptions.SO_REUSEADDR)).booleanValue();
  11. }

相关文章