1 /* 2 * Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package java.net; 27 28 import java.io.InputStream; 29 import java.io.OutputStream; 30 import java.io.IOException; 31 import java.io.InterruptedIOException; 32 import java.nio.channels.SocketChannel; 33 import java.security.AccessController; 34 import java.security.PrivilegedExceptionAction; 35 import java.security.PrivilegedAction; 36 37 /** 38 * This class implements client sockets (also called just 39 * "sockets"). A socket is an endpoint for communication 40 * between two machines. 41 *
 42 * The actual work of the socket is performed by an instance of the 43 * SocketImpl class. An application, by changing 44 * the socket factory that creates the socket implementation, 45 * can configure itself to create sockets appropriate to the local 46 * firewall. 47 * 48 * @author unascribed 49 * @see java.net.Socket#setSocketImplFactory(java.net.SocketImplFactory) 50 * @see java.net.SocketImpl 51 * @see java.nio.channels.SocketChannel 52 * @since JDK1.0 53 */ 54 public 55 class Socket implements java.io.Closeable { 56 /** 57 * Various states of this socket. 58 */ 59 private boolean created = false; 60 private boolean bound = false; 61 private boolean connected = false; 62 private boolean closed = false; 63 private Object closeLock = new Object(); 64 private boolean shutIn = false; 65 private boolean shutOut = false; 66 67 /** 68 * The implementation of this Socket. 69 */ 70 SocketImpl impl; 71 72 /** 73 * Are we using an older SocketImpl? 74 */ 75 private boolean oldImpl = false; 76 77 /** 78 * Creates an unconnected socket, with the 79 * system-default type of SocketImpl. 80 * 81 * @since JDK1.1 82 * @revised 1.4 83 */ 84 public Socket() { 85 setImpl(); 86 } 87 88 /** 89 * Creates an unconnected socket, specifying the type of proxy, if any, 90 * that should be used regardless of any other settings. 91 *
 92 * If there is a security manager, its checkConnect method 93 * is called with the proxy host address and port number 94 * as its arguments. This could result in a SecurityException. 95 *
 96 * Examples: 97 *

Socket s = new Socket(Proxy.NO_PROXY); will create 98 * a plain socket ignoring any other proxy configuration.
 99 *
Socket s = new Socket(new Proxy(Proxy.Type.SOCKS, new InetSocketAddress("socks.mydom.com", 1080))); 100 * will create a socket connecting through the specified SOCKS proxy 101 * server.
 102 *
 103 * 104 * @param proxy a {@link java.net.Proxy Proxy} object specifying what kind 105 * of proxying should be used. 106 * @throws IllegalArgumentException if the proxy is of an invalid type 107 * or null. 108 * @throws SecurityException if a security manager is present and 109 * permission to connect to the proxy is 110 * denied. 111 * @see java.net.ProxySelector 112 * @see java.net.Proxy 113 * 114 * @since 1.5 115 */ 116 public Socket(Proxy proxy) { 117 // Create a copy of Proxy as a security measure 118 if (proxy == null) { 119 throw new IllegalArgumentException("Invalid Proxy"); 120 } 121 Proxy p = proxy == Proxy.NO_PROXY ? Proxy.NO_PROXY : sun.net.ApplicationProxy.create(proxy); 122 if (p.type() == Proxy.Type.SOCKS) { 123 SecurityManager security = System.getSecurityManager(); 124 InetSocketAddress epoint = (InetSocketAddress) p.address(); 125 if (epoint.getAddress() != null) { 126 checkAddress (epoint.getAddress(), "Socket"); 127 } 128 if (security != null) { 129 if (epoint.isUnresolved()) 130 epoint = new InetSocketAddress(epoint.getHostName(), epoint.getPort()); 131 if (epoint.isUnresolved()) 132 security.checkConnect(epoint.getHostName(), epoint.getPort()); 133 else 134 security.checkConnect(epoint.getAddress().getHostAddress(), 135 epoint.getPort()); 136 } 137 impl = new SocksSocketImpl(p); 138 impl.setSocket(this); 139 } else { 140 if (p == Proxy.NO_PROXY) { 141 if (factory == null) { 142 impl = new PlainSocketImpl(); 143 impl.setSocket(this); 144 } else 145 setImpl(); 146 } else 147 throw new IllegalArgumentException("Invalid Proxy"); 148 } 149 } 150 151 /** 152 * Creates an unconnected Socket with a user-specified 153 * SocketImpl. 154 *
 155 * @param impl an instance of a SocketImpl 156 * the subclass wishes to use on the Socket. 157 * 158 * @exception SocketException if there is an error in the underlying protocol, 159 * such as a TCP error. 160 * @since JDK1.1 161 */ 162 protected Socket(SocketImpl impl) throws SocketException { 163 this.impl = impl; 164 if (impl != null) { 165 checkOldImpl(); 166 this.impl.setSocket(this); 167 } 168 } 169 170 /** 171 * Creates a stream socket and connects it to the specified port 172 * number on the named host. 173 *
 174 * If the specified host is <tt>null</tt> it is the equivalent of 175 * specifying the address as <tt>{@link java.net.InetAddress#getByName InetAddress.getByName}(null)</tt>. 176 * In other words, it is equivalent to specifying an address of the 177 * loopback interface.
 178 *
 179 * If the application has specified a server socket factory, that 180 * factory's createSocketImpl method is called to create 181 * the actual socket implementation. Otherwise a "plain" socket is created. 182 *
 183 * If there is a security manager, its 184 * checkConnect method is called 185 * with the host address and port 186 * as its arguments. This could result in a SecurityException. 187 * 188 * @param host the host name, or null for the loopback address. 189 * @param port the port number. 190 * 191 * @exception UnknownHostException if the IP address of 192 * the host could not be determined. 193 * 194 * @exception IOException if an I/O error occurs when creating the socket. 195 * @exception SecurityException if a security manager exists and its 196 * checkConnect method doesn't allow the operation. 197 * @exception IllegalArgumentException if the port parameter is outside 198 * the specified range of valid port values, which is between 199 * 0 and 65535, inclusive. 200 * @see java.net.Socket#setSocketImplFactory(java.net.SocketImplFactory) 201 * @see java.net.SocketImpl 202 * @see java.net.SocketImplFactory#createSocketImpl() 203 * @see SecurityManager#checkConnect 204 */ 205 public Socket(String host, int port) 206 throws UnknownHostException, IOException 207 { 208 this(host != null ? new InetSocketAddress(host, port) : 209 new InetSocketAddress(InetAddress.getByName(null), port), 210 (SocketAddress) null, true); 211 } 212 213 /** 214 * Creates a stream socket and connects it to the specified port 215 * number at the specified IP address. 216 *
 217 * If the application has specified a socket factory, that factory's 218 * createSocketImpl method is called to create the 219 * actual socket implementation. Otherwise a "plain" socket is created. 220 *
 221 * If there is a security manager, its 222 * checkConnect method is called 223 * with the host address and port 224 * as its arguments. This could result in a SecurityException. 225 * 226 * @param address the IP address. 227 * @param port the port number. 228 * @exception IOException if an I/O error occurs when creating the socket. 229 * @exception SecurityException if a security manager exists and its 230 * checkConnect method doesn't allow the operation. 231 * @exception IllegalArgumentException if the port parameter is outside 232 * the specified range of valid port values, which is between 233 * 0 and 65535, inclusive. 234 * @exception NullPointerException if address is null. 235 * @see java.net.Socket#setSocketImplFactory(java.net.SocketImplFactory) 236 * @see java.net.SocketImpl 237 * @see java.net.SocketImplFactory#createSocketImpl() 238 * @see SecurityManager#checkConnect 239 */ 240 public Socket(InetAddress address, int port) throws IOException { 241 this(address != null ? new InetSocketAddress(address, port) : null, 242 (SocketAddress) null, true); 243 } 244 245 /** 246 * Creates a socket and connects it to the specified remote host on 247 * the specified remote port. The Socket will also bind() to the local 248 * address and port supplied. 249 *
 250 * If the specified host is <tt>null</tt> it is the equivalent of 251 * specifying the address as <tt>{@link java.net.InetAddress#getByName InetAddress.getByName}(null)</tt>. 252 * In other words, it is equivalent to specifying an address of the 253 * loopback interface.
 254 *
 255 * A local port number of zero will let the system pick up a 256 * free port in the bind operation.
 257 *
 258 * If there is a security manager, its 259 * checkConnect method is called 260 * with the host address and port 261 * as its arguments. This could result in a SecurityException. 262 * 263 * @param host the name of the remote host, or null for the loopback address. 264 * @param port the remote port 265 * @param localAddr the local address the socket is bound to, or 266 * null for the anyLocal address. 267 * @param localPort the local port the socket is bound to, or 268 * zero for a system selected free port. 269 * @exception IOException if an I/O error occurs when creating the socket. 270 * @exception SecurityException if a security manager exists and its 271 * checkConnect method doesn't allow the operation. 272 * @exception IllegalArgumentException if the port parameter or localPort 273 * parameter is outside the specified range of valid port values, 274 * which is between 0 and 65535, inclusive. 275 * @see SecurityManager#checkConnect 276 * @since JDK1.1 277 */ 278 public Socket(String host, int port, InetAddress localAddr, 279 int localPort) throws IOException { 280 this(host != null ? new InetSocketAddress(host, port) : 281 new InetSocketAddress(InetAddress.getByName(null), port), 282 new InetSocketAddress(localAddr, localPort), true); 283 } 284 285 /** 286 * Creates a socket and connects it to the specified remote address on 287 * the specified remote port. The Socket will also bind() to the local 288 * address and port supplied. 289 *
 290 * If the specified local address is <tt>null</tt> it is the equivalent of 291 * specifying the address as the AnyLocal address (see <tt>{@link java.net.InetAddress#isAnyLocalAddress InetAddress.isAnyLocalAddress}()</tt>). 292 *
 293 * A local port number of zero will let the system pick up a 294 * free port in the bind operation.
 295 *
 296 * If there is a security manager, its 297 * checkConnect method is called 298 * with the host address and port 299 * as its arguments. This could result in a SecurityException. 300 * 301 * @param address the remote address 302 * @param port the remote port 303 * @param localAddr the local address the socket is bound to, or 304 * null for the anyLocal address. 305 * @param localPort the local port the socket is bound to or 306 * zero for a system selected free port. 307 * @exception IOException if an I/O error occurs when creating the socket. 308 * @exception SecurityException if a security manager exists and its 309 * checkConnect method doesn't allow the operation. 310 * @exception IllegalArgumentException if the port parameter or localPort 311 * parameter is outside the specified range of valid port values, 312 * which is between 0 and 65535, inclusive. 313 * @exception NullPointerException if address is null. 314 * @see SecurityManager#checkConnect 315 * @since JDK1.1 316 */ 317 public Socket(InetAddress address, int port, InetAddress localAddr, 318 int localPort) throws IOException { 319 this(address != null ? new InetSocketAddress(address, port) : null, 320 new InetSocketAddress(localAddr, localPort), true); 321 } 322 323 /** 324 * Creates a stream socket and connects it to the specified port 325 * number on the named host. 326 *
 327 * If the specified host is <tt>null</tt> it is the equivalent of 328 * specifying the address as <tt>{@link java.net.InetAddress#getByName InetAddress.getByName}(null)</tt>. 329 * In other words, it is equivalent to specifying an address of the 330 * loopback interface.
 331 *
 332 * If the stream argument is true, this creates a 333 * stream socket. If the stream argument is false, it 334 * creates a datagram socket. 335 *
 336 * If the application has specified a server socket factory, that 337 * factory's createSocketImpl method is called to create 338 * the actual socket implementation. Otherwise a "plain" socket is created. 339 *
 340 * If there is a security manager, its 341 * checkConnect method is called 342 * with the host address and port 343 * as its arguments. This could result in a SecurityException. 344 *
 345 * If a UDP socket is used, TCP/IP related socket options will not apply. 346 * 347 * @param host the host name, or null for the loopback address. 348 * @param port the port number. 349 * @param stream a boolean indicating whether this is 350 * a stream socket or a datagram socket. 351 * @exception IOException if an I/O error occurs when creating the socket. 352 * @exception SecurityException if a security manager exists and its 353 * checkConnect method doesn't allow the operation. 354 * @exception IllegalArgumentException if the port parameter is outside 355 * the specified range of valid port values, which is between 356 * 0 and 65535, inclusive. 357 * @see java.net.Socket#setSocketImplFactory(java.net.SocketImplFactory) 358 * @see java.net.SocketImpl 359 * @see java.net.SocketImplFactory#createSocketImpl() 360 * @see SecurityManager#checkConnect 361 * @deprecated Use DatagramSocket instead for UDP transport. 362 */ 363 @Deprecated 364 public Socket(String host, int port, boolean stream) throws IOException { 365 this(host != null ? new InetSocketAddress(host, port) : 366 new InetSocketAddress(InetAddress.getByName(null), port), 367 (SocketAddress) null, stream); 368 } 369 370 /** 371 * Creates a socket and connects it to the specified port number at 372 * the specified IP address. 373 *
 374 * If the stream argument is true, this creates a 375 * stream socket. If the stream argument is false, it 376 * creates a datagram socket. 377 *
 378 * If the application has specified a server socket factory, that 379 * factory's createSocketImpl method is called to create 380 * the actual socket implementation. Otherwise a "plain" socket is created. 381 * 382 *
If there is a security manager, its 383 * checkConnect method is called 384 * with host.getHostAddress() and port 385 * as its arguments. This could result in a SecurityException. 386 *
 387 * If UDP socket is used, TCP/IP related socket options will not apply. 388 * 389 * @param host the IP address. 390 * @param port the port number. 391 * @param stream if true, create a stream socket; 392 * otherwise, create a datagram socket. 393 * @exception IOException if an I/O error occurs when creating the socket. 394 * @exception SecurityException if a security manager exists and its 395 * checkConnect method doesn't allow the operation. 396 * @exception IllegalArgumentException if the port parameter is outside 397 * the specified range of valid port values, which is between 398 * 0 and 65535, inclusive. 399 * @exception NullPointerException if host is null. 400 * @see java.net.Socket#setSocketImplFactory(java.net.SocketImplFactory) 401 * @see java.net.SocketImpl 402 * @see java.net.SocketImplFactory#createSocketImpl() 403 * @see SecurityManager#checkConnect 404 * @deprecated Use DatagramSocket instead for UDP transport. 405 */ 406 @Deprecated 407 public Socket(InetAddress host, int port, boolean stream) throws IOException { 408 this(host != null ? new InetSocketAddress(host, port) : null, 409 new InetSocketAddress(0), stream); 410 } 411 412 private Socket(SocketAddress address, SocketAddress localAddr, 413 boolean stream) throws IOException { 414 setImpl(); 415 416 // backward compatibility 417 if (address == null) 418 throw new NullPointerException(); 419 420 try { 421 createImpl(stream); 422 if (localAddr != null) 423 bind(localAddr); 424 if (address != null) 425 connect(address); 426 } catch (IOException e) { 427 close(); 428 throw e; 429 } 430 } 431 432 /** 433 * Creates the socket implementation. 434 * 435 * @param stream a boolean value : true for a TCP socket, 436 * false for UDP. 437 * @throws IOException if creation fails 438 * @since 1.4 439 */ 440 void createImpl(boolean stream) throws SocketException { 441 if (impl == null) 442 setImpl(); 443 try { 444 impl.create(stream); 445 created = true; 446 } catch (IOException e) { 447 throw new SocketException(e.getMessage()); 448 } 449 } 450 451 private void checkOldImpl() { 452 if (impl == null) 453 return; 454 // SocketImpl.connect() is a protected method, therefore we need to use 455 // getDeclaredMethod, therefore we need permission to access the member 456 457 oldImpl = AccessController.doPrivileged 458 (new PrivilegedAction<Boolean>() { 459 public Boolean run() { 460 Class[] cl = new Class[2]; 461 cl[0] = SocketAddress.class; 462 cl[1] = Integer.TYPE; 463 Class clazz = impl.getClass(); 464 while (true) { 465 try { 466 clazz.getDeclaredMethod("connect", cl); 467 return Boolean.FALSE; 468 } catch (NoSuchMethodException e) { 469 clazz = clazz.getSuperclass(); 470 // java.net.SocketImpl class will always have this abstract method. 471 // If we have not found it by now in the hierarchy then it does not 472 // exist, we are an old style impl. 473 if (clazz.equals(java.net.SocketImpl.class)) { 474 return Boolean.TRUE; 475 } 476 } 477 } 478 } 479 }); 480 } 481 482 /** 483 * Sets impl to the system-default type of SocketImpl. 484 * @since 1.4 485 */ 486 void setImpl() { 487 if (factory != null) { 488 impl = factory.createSocketImpl(); 489 checkOldImpl(); 490 } else { 491 // No need to do a checkOldImpl() here, we know it's an up to date 492 // SocketImpl! 493 impl = new SocksSocketImpl(); 494 } 495 if (impl != null) 496 impl.setSocket(this); 497 } 498 499 500 /** 501 * Get the SocketImpl attached to this socket, creating 502 * it if necessary. 503 * 504 * @return the SocketImpl attached to that ServerSocket. 505 * @throws SocketException if creation fails 506 * @since 1.4 507 */ 508 SocketImpl getImpl() throws SocketException { 509 if (!created) 510 createImpl(true); 511 return impl; 512 } 513 514 /** 515 * Connects this socket to the server. 516 * 517 * @param endpoint the SocketAddress 518 * @throws IOException if an error occurs during the connection 519 * @throws java.nio.channels.IllegalBlockingModeException 520 * if this socket has an associated channel, 521 * and the channel is in non-blocking mode 522 * @throws IllegalArgumentException if endpoint is null or is a 523 * SocketAddress subclass not supported by this socket 524 * @since 1.4 525 * @spec JSR-51 526 */ 527 public void connect(SocketAddress endpoint) throws IOException { 528 connect(endpoint, 0); 529 } 530 531 /** 532 * Connects this socket to the server with a specified timeout value. 533 * A timeout of zero is interpreted as an infinite timeout. The connection 534 * will then block until established or an error occurs. 535 * 536 * @param endpoint the SocketAddress 537 * @param timeout the timeout value to be used in milliseconds. 538 * @throws IOException if an error occurs during the connection 539 * @throws SocketTimeoutException if timeout expires before connecting 540 * @throws java.nio.channels.IllegalBlockingModeException 541 * if this socket has an associated channel, 542 * and the channel is in non-blocking mode 543 * @throws IllegalArgumentException if endpoint is null or is a 544 * SocketAddress subclass not supported by this socket 545 * @since 1.4 546 * @spec JSR-51 547 */ 548 public void connect(SocketAddress endpoint, int timeout) throws IOException { 549 if (endpoint == null) 550 throw new IllegalArgumentException("connect: The address can't be null"); 551 552 if (timeout < 0) 553 throw new IllegalArgumentException("connect: timeout can't be negative"); 554 555 if (isClosed()) 556 throw new SocketException("Socket is closed"); 557 558 if (!oldImpl && isConnected()) 559 throw new SocketException("already connected"); 560 561 if (!(endpoint instanceof InetSocketAddress)) 562 throw new IllegalArgumentException("Unsupported address type"); 563 564 InetSocketAddress epoint = (InetSocketAddress) endpoint; 565 InetAddress addr = epoint.getAddress (); 566 int port = epoint.getPort(); 567 checkAddress(addr, "connect"); 568 569 SecurityManager security = System.getSecurityManager(); 570 if (security != null) { 571 if (epoint.isUnresolved()) 572 security.checkConnect(epoint.getHostName(), port); 573 else 574 security.checkConnect(addr.getHostAddress(), port); 575 } 576 if (!created) 577 createImpl(true); 578 if (!oldImpl) 579 impl.connect(epoint, timeout); 580 else if (timeout == 0) { 581 if (epoint.isUnresolved()) 582 impl.connect(addr.getHostName(), port); 583 else 584 impl.connect(addr, port); 585 } else 586 throw new UnsupportedOperationException("SocketImpl.connect(addr, timeout)"); 587 connected = true; 588 /* 589 * If the socket was not bound before the connect, it is now because 590 * the kernel will have picked an ephemeral port & a local address 591 */ 592 bound = true; 593 } 594 595 /** 596 * Binds the socket to a local address. 597 *
 598 * If the address is null, then the system will pick up 599 * an ephemeral port and a valid local address to bind the socket. 600 * 601 * @param bindpoint the SocketAddress to bind to 602 * @throws IOException if the bind operation fails, or if the socket 603 * is already bound. 604 * @throws IllegalArgumentException if bindpoint is a 605 * SocketAddress subclass not supported by this socket 606 * 607 * @since 1.4 608 * @see #isBound 609 */ 610 public void bind(SocketAddress bindpoint) throws IOException { 611 if (isClosed()) 612 throw new SocketException("Socket is closed"); 613 if (!oldImpl && isBound()) 614 throw new SocketException("Already bound"); 615 616 if (bindpoint != null && (!(bindpoint instanceof InetSocketAddress))) 617 throw new IllegalArgumentException("Unsupported address type"); 618 InetSocketAddress epoint = (InetSocketAddress) bindpoint; 619 if (epoint != null && epoint.isUnresolved()) 620 throw new SocketException("Unresolved address"); 621 if (epoint == null) { 622 epoint = new InetSocketAddress(0); 623 } 624 InetAddress addr = epoint.getAddress(); 625 int port = epoint.getPort(); 626 checkAddress (addr, "bind"); 627 getImpl().bind (addr, port); 628 bound = true; 629 } 630 631 private void checkAddress (InetAddress addr, String op) { 632 if (addr == null) { 633 return; 634 } 635 if (!(addr instanceof Inet4Address || addr instanceof Inet6Address)) { 636 throw new IllegalArgumentException(op + ": invalid address type"); 637 } 638 } 639 640 /** 641 * set the flags after an accept() call. 642 */ 643 final void postAccept() { 644 connected = true; 645 created = true; 646 bound = true; 647 } 648 649 void setCreated() { 650 created = true; 651 } 652 653 void setBound() { 654 bound = true; 655 } 656 657 void setConnected() { 658 connected = true; 659 } 660 661 /** 662 * Returns the address to which the socket is connected. 663 *
 664 * If the socket was connected prior to being {@link #close closed}, 665 * then this method will continue to return the connected address 666 * after the socket is closed. 667 * 668 * @return the remote IP address to which this socket is connected, 669 * or null if the socket is not connected. 670 */ 671 public InetAddress getInetAddress() { 672 if (!isConnected()) 673 return null; 674 try { 675 return getImpl().getInetAddress(); 676 } catch (SocketException e) { 677 } 678 return null; 679 } 680 681 /** 682 * Gets the local address to which the socket is bound. 683 * 684 * @return the local address to which the socket is bound, or 685 * the {@link InetAddress#isAnyLocalAddress wildcard} address 686 * if the socket is closed or not bound yet. 687 * @since JDK1.1 688 */ 689 public InetAddress getLocalAddress() { 690 // This is for backward compatibility 691 if (!isBound()) 692 return InetAddress.anyLocalAddress(); 693 InetAddress in = null; 694 try { 695 in = (InetAddress) getImpl().getOption(SocketOptions.SO_BINDADDR); 696 if (in.isAnyLocalAddress()) { 697 in = InetAddress.anyLocalAddress(); 698 } 699 } catch (Exception e) { 700 in = InetAddress.anyLocalAddress(); // "<IP_ADDRESS>" 701 } 702 return in; 703 } 704 705 /** 706 * Returns the remote port number to which this socket is connected. 707 *
 708 * If the socket was connected prior to being {@link #close closed}, 709 * then this method will continue to return the connected port number 710 * after the socket is closed. 711 * 712 * @return the remote port number to which this socket is connected, or 713 * 0 if the socket is not connected yet. 714 */ 715 public int getPort() { 716 if (!isConnected()) 717 return 0; 718 try { 719 return getImpl().getPort(); 720 } catch (SocketException e) { 721 // Shouldn't happen as we're connected 722 } 723 return -1; 724 } 725 726 /** 727 * Returns the local port number to which this socket is bound. 728 *
 729 * If the socket was bound prior to being {@link #close closed}, 730 * then this method will continue to return the local port number 731 * after the socket is closed. 732 * 733 * @return the local port number to which this socket is bound or -1 734 * if the socket is not bound yet. 735 */ 736 public int getLocalPort() { 737 if (!isBound()) 738 return -1; 739 try { 740 return getImpl().getLocalPort(); 741 } catch(SocketException e) { 742 // shouldn't happen as we're bound 743 } 744 return -1; 745 } 746 747 /** 748 * Returns the address of the endpoint this socket is connected to, or 749 * null if it is unconnected. 750 *
 751 * If the socket was connected prior to being {@link #close closed}, 752 * then this method will continue to return the connected address 753 * after the socket is closed. 754 * 755 756 * @return a SocketAddress representing the remote endpoint of this 757 * socket, or null if it is not connected yet. 758 * @see #getInetAddress() 759 * @see #getPort() 760 * @see #connect(SocketAddress, int) 761 * @see #connect(SocketAddress) 762 * @since 1.4 763 */ 764 public SocketAddress getRemoteSocketAddress() { 765 if (!isConnected()) 766 return null; 767 return new InetSocketAddress(getInetAddress(), getPort()); 768 } 769 770 /** 771 * Returns the address of the endpoint this socket is bound to, or 772 * null if it is not bound yet. 773 *
 774 * If a socket bound to an endpoint represented by an 775 * InetSocketAddress  is {@link #close closed}, 776 * then this method will continue to return an InetSocketAddress 777 * after the socket is closed. In that case the returned 778 * InetSocketAddress's address is the 779 * {@link InetAddress#isAnyLocalAddress wildcard} address 780 * and its port is the local port that it was bound to. 781 * 782 * @return a SocketAddress representing the local endpoint of this 783 * socket, or null if it is not bound yet. 784 * @see #getLocalAddress() 785 * @see #getLocalPort() 786 * @see #bind(SocketAddress) 787 * @since 1.4 788 */ 789 790 public SocketAddress getLocalSocketAddress() { 791 if (!isBound()) 792 return null; 793 return new InetSocketAddress(getLocalAddress(), getLocalPort()); 794 } 795 796 /** 797 * Returns the unique {@link java.nio.channels.SocketChannel SocketChannel} 798 * object associated with this socket, if any. 799 * 800 *
 A socket will have a channel if, and only if, the channel itself was 801 * created via the {@link java.nio.channels.SocketChannel#open 802 * SocketChannel.open} or {@link 803 * java.nio.channels.ServerSocketChannel#accept ServerSocketChannel.accept} 804 * methods. 805 * 806 * @return the socket channel associated with this socket, 807 * or <tt>null</tt> if this socket was not created 808 * for a channel 809 * 810 * @since 1.4 811 * @spec JSR-51 812 */ 813 public SocketChannel getChannel() { 814 return null; 815 } 816 817 /** 818 * Returns an input stream for this socket. 819 * 820 *
 If this socket has an associated channel then the resulting input 821 * stream delegates all of its operations to the channel. If the channel 822 * is in non-blocking mode then the input stream's <tt>read</tt> operations 823 * will throw an {@link java.nio.channels.IllegalBlockingModeException}. 824 * 825 *
Under abnormal conditions the underlying connection may be 826 * broken by the remote host or the network software (for example 827 * a connection reset in the case of TCP connections). When a 828 * broken connection is detected by the network software the 829 * following applies to the returned input stream :- 830 * 831 *
 832 * 833 *

The network software may discard bytes that are buffered 834 * by the socket. Bytes that aren't discarded by the network 835 * software can be read using {@link java.io.InputStream#read read}. 836 * 837 *

If there are no bytes buffered on the socket, or all 838 * buffered bytes have been consumed by 839 * {@link java.io.InputStream#read read}, then all subsequent 840 * calls to {@link java.io.InputStream#read read} will throw an 841 * {@link java.io.IOException IOException}. 842 * 843 *

If there are no bytes buffered on the socket, and the 844 * socket has not been closed using {@link #close close}, then 845 * {@link java.io.InputStream#available available} will 846 * return 0. 847 * 848 *
 849 * 850 *
 Closing the returned {@link java.io.InputStream InputStream} 851 * will close the associated socket. 852 * 853 * @return an input stream for reading bytes from this socket. 854 * @exception IOException if an I/O error occurs when creating the 855 * input stream, the socket is closed, the socket is 856 * not connected, or the socket input has been shutdown 857 * using {@link #shutdownInput()} 858 * 859 * @revised 1.4 860 * @spec JSR-51 861 */ 862 public InputStream getInputStream() throws IOException { 863 if (isClosed()) 864 throw new SocketException("Socket is closed"); 865 if (!isConnected()) 866 throw new SocketException("Socket is not connected"); 867 if (isInputShutdown()) 868 throw new SocketException("Socket input is shutdown"); 869 final Socket s = this; 870 InputStream is = null; 871 try { 872 is = AccessController.doPrivileged( 873 new PrivilegedExceptionAction<InputStream>() { 874 public InputStream run() throws IOException { 875 return impl.getInputStream(); 876 } 877 }); 878 } catch (java.security.PrivilegedActionException e) { 879 throw (IOException) e.getException(); 880 } 881 return is; 882 } 883 884 /** 885 * Returns an output stream for this socket. 886 * 887 *
 If this socket has an associated channel then the resulting output 888 * stream delegates all of its operations to the channel. If the channel 889 * is in non-blocking mode then the output stream's <tt>write</tt> 890 * operations will throw an {@link 891 * java.nio.channels.IllegalBlockingModeException}. 892 * 893 *
 Closing the returned {@link java.io.OutputStream OutputStream} 894 * will close the associated socket. 895 * 896 * @return an output stream for writing bytes to this socket. 897 * @exception IOException if an I/O error occurs when creating the 898 * output stream or if the socket is not connected. 899 * @revised 1.4 900 * @spec JSR-51 901 */ 902 public OutputStream getOutputStream() throws IOException { 903 if (isClosed()) 904 throw new SocketException("Socket is closed"); 905 if (!isConnected()) 906 throw new SocketException("Socket is not connected"); 907 if (isOutputShutdown()) 908 throw new SocketException("Socket output is shutdown"); 909 final Socket s = this; 910 OutputStream os = null; 911 try { 912 os = AccessController.doPrivileged( 913 new PrivilegedExceptionAction<OutputStream>() { 914 public OutputStream run() throws IOException { 915 return impl.getOutputStream(); 916 } 917 }); 918 } catch (java.security.PrivilegedActionException e) { 919 throw (IOException) e.getException(); 920 } 921 return os; 922 } 923 924 /** 925 * Enable/disable TCP_NODELAY (disable/enable Nagle's algorithm). 926 * 927 * @param on true to enable TCP_NODELAY, 928 * false to disable. 929 * 930 * @exception SocketException if there is an error 931 * in the underlying protocol, such as a TCP error. 932 * 933 * @since JDK1.1 934 * 935 * @see #getTcpNoDelay() 936 */ 937 public void setTcpNoDelay(boolean on) throws SocketException { 938 if (isClosed()) 939 throw new SocketException("Socket is closed"); 940 getImpl().setOption(SocketOptions.TCP_NODELAY, Boolean.valueOf(on)); 941 } 942 943 /** 944 * Tests if TCP_NODELAY is enabled. 945 * 946 * @return a boolean indicating whether or not TCP_NODELAY is enabled. 947 * @exception SocketException if there is an error 948 * in the underlying protocol, such as a TCP error. 949 * @since JDK1.1 950 * @see #setTcpNoDelay(boolean) 951 */ 952 public boolean getTcpNoDelay() throws SocketException { 953 if (isClosed()) 954 throw new SocketException("Socket is closed"); 955 return ((Boolean) getImpl().getOption(SocketOptions.TCP_NODELAY)).booleanValue(); 956 } 957 958 /** 959 * Enable/disable SO_LINGER with the specified linger time in seconds. 960 * The maximum timeout value is platform specific. 961 * 962 * The setting only affects socket close. 963 * 964 * @param on whether or not to linger on. 965 * @param linger how long to linger for, if on is true. 966 * @exception SocketException if there is an error 967 * in the underlying protocol, such as a TCP error. 968 * @exception IllegalArgumentException if the linger value is negative. 969 * @since JDK1.1 970 * @see #getSoLinger() 971 */ 972 public void setSoLinger(boolean on, int linger) throws SocketException { 973 if (isClosed()) 974 throw new SocketException("Socket is closed"); 975 if (!on) { 976 getImpl().setOption(SocketOptions.SO_LINGER, new Boolean(on)); 977 } else { 978 if (linger < 0) { 979 throw new IllegalArgumentException("invalid value for SO_LINGER"); 980 } 981 if (linger > 65535) 982 linger = 65535; 983 getImpl().setOption(SocketOptions.SO_LINGER, new Integer(linger)); 984 } 985 } 986 987 /** 988 * Returns setting for SO_LINGER. -1 returns implies that the 989 * option is disabled. 990 * 991 * The setting only affects socket close. 992 * 993 * @return the setting for SO_LINGER. 994 * @exception SocketException if there is an error 995 * in the underlying protocol, such as a TCP error. 996 * @since JDK1.1 997 * @see #setSoLinger(boolean, int) 998 */ 999 public int getSoLinger() throws SocketException { 1000 if (isClosed()) 1001 throw new SocketException("Socket is closed"); 1002 Object o = getImpl().getOption(SocketOptions.SO_LINGER); 1003 if (o instanceof Integer) { 1004 return ((Integer) o).intValue(); 1005 } else { 1006 return -1; 1007 } 1008 } 1009 1010 /** 1011 * Send one byte of urgent data on the socket. The byte to be sent is the lowest eight 1012 * bits of the data parameter. The urgent byte is 1013 * sent after any preceding writes to the socket OutputStream 1014 * and before any future writes to the OutputStream. 1015 * @param data The byte of data to send 1016 * @exception IOException if there is an error 1017 * sending the data. 1018 * @since 1.4 1019 */ 1020 public void sendUrgentData (int data) throws IOException { 1021 if (!getImpl().supportsUrgentData ()) { 1022 throw new SocketException ("Urgent data not supported"); 1023 } 1024 getImpl().sendUrgentData (data); 1025 } 1026 1027 /** 1028 * Enable/disable OOBINLINE (receipt of TCP urgent data) 1029 * 1030 * By default, this option is disabled and TCP urgent data received on a 1031 * socket is silently discarded. If the user wishes to receive urgent data, then 1032 * this option must be enabled. When enabled, urgent data is received 1033 * inline with normal data. 1034 *
 1035 * Note, only limited support is provided for handling incoming urgent 1036 * data. In particular, no notification of incoming urgent data is provided 1037 * and there is no capability to distinguish between normal data and urgent 1038 * data unless provided by a higher level protocol. 1039 * 1040 * @param on true to enable OOBINLINE, 1041 * false to disable. 1042 * 1043 * @exception SocketException if there is an error 1044 * in the underlying protocol, such as a TCP error. 1045 * 1046 * @since 1.4 1047 * 1048 * @see #getOOBInline() 1049 */ 1050 public void setOOBInline(boolean on) throws SocketException { 1051 if (isClosed()) 1052 throw new SocketException("Socket is closed"); 1053 getImpl().setOption(SocketOptions.SO_OOBINLINE, Boolean.valueOf(on)); 1054 } 1055 1056 /** 1057 * Tests if OOBINLINE is enabled. 1058 * 1059 * @return a boolean indicating whether or not OOBINLINE is enabled. 1060 * @exception SocketException if there is an error 1061 * in the underlying protocol, such as a TCP error. 1062 * @since 1.4 1063 * @see #setOOBInline(boolean) 1064 */ 1065 public boolean getOOBInline() throws SocketException { 1066 if (isClosed()) 1067 throw new SocketException("Socket is closed"); 1068 return ((Boolean) getImpl().getOption(SocketOptions.SO_OOBINLINE)).booleanValue(); 1069 } 1070 1071 /** 1072 * Enable/disable SO_TIMEOUT with the specified timeout, in 1073 * milliseconds. With this option set to a non-zero timeout, 1074 * a read() call on the InputStream associated with this Socket 1075 * will block for only this amount of time. If the timeout expires, 1076 * a java.net.SocketTimeoutException is raised, though the 1077 * Socket is still valid. The option must be enabled 1078 * prior to entering the blocking operation to have effect. The 1079 * timeout must be > 0. 1080 * A timeout of zero is interpreted as an infinite timeout. 1081 * @param timeout the specified timeout, in milliseconds. 1082 * @exception SocketException if there is an error 1083 * in the underlying protocol, such as a TCP error. 1084 * @since JDK 1.1 1085 * @see #getSoTimeout() 1086 */ 1087 public synchronized void setSoTimeout(int timeout) throws SocketException { 1088 if (isClosed()) 1089 throw new SocketException("Socket is closed"); 1090 if (timeout < 0) 1091 throw new IllegalArgumentException("timeout can't be negative"); 1092 1093 getImpl().setOption(SocketOptions.SO_TIMEOUT, new Integer(timeout)); 1094 } 1095 1096 /** 1097 * Returns setting for SO_TIMEOUT. 0 returns implies that the 1098 * option is disabled (i.e., timeout of infinity). 1099 * @return the setting for SO_TIMEOUT 1100 * @exception SocketException if there is an error 1101 * in the underlying protocol, such as a TCP error. 1102 * @since JDK1.1 1103 * @see #setSoTimeout(int) 1104 */ 1105 public synchronized int getSoTimeout() throws SocketException { 1106 if (isClosed()) 1107 throw new SocketException("Socket is closed"); 1108 Object o = getImpl().getOption(SocketOptions.SO_TIMEOUT); 1109 /* extra type safety */ 1110 if (o instanceof Integer) { 1111 return ((Integer) o).intValue(); 1112 } else { 1113 return 0; 1114 } 1115 } 1116 1117 /** 1118 * Sets the SO_SNDBUF option to the specified value for this 1119 * <tt>Socket</tt>. The SO_SNDBUF option is used by the platform's 1120 * networking code as a hint for the size to set 1121 * the underlying network I/O buffers. 1122 * 1123 *
Because SO_SNDBUF is a hint, applications that want to 1124 * verify what size the buffers were set to should call 1125 * {@link #getSendBufferSize()}. 1126 * 1127 * @exception SocketException if there is an error 1128 * in the underlying protocol, such as a TCP error. 1129 * 1130 * @param size the size to which to set the send buffer 1131 * size. This value must be greater than 0. 1132 * 1133 * @exception IllegalArgumentException if the 1134 * value is 0 or is negative. 1135 * 1136 * @see #getSendBufferSize() 1137 * @since 1.2 1138 */ 1139 public synchronized void setSendBufferSize(int size) 1140 throws SocketException{ 1141 if (!(size > 0)) { 1142 throw new IllegalArgumentException("negative send size"); 1143 } 1144 if (isClosed()) 1145 throw new SocketException("Socket is closed"); 1146 getImpl().setOption(SocketOptions.SO_SNDBUF, new Integer(size)); 1147 } 1148 1149 /** 1150 * Get value of the SO_SNDBUF option for this <tt>Socket</tt>, 1151 * that is the buffer size used by the platform 1152 * for output on this <tt>Socket</tt>. 1153 * @return the value of the SO_SNDBUF option for this <tt>Socket</tt>. 1154 * 1155 * @exception SocketException if there is an error 1156 * in the underlying protocol, such as a TCP error. 1157 * 1158 * @see #setSendBufferSize(int) 1159 * @since 1.2 1160 */ 1161 public synchronized int getSendBufferSize() throws SocketException { 1162 if (isClosed()) 1163 throw new SocketException("Socket is closed"); 1164 int result = 0; 1165 Object o = getImpl().getOption(SocketOptions.SO_SNDBUF); 1166 if (o instanceof Integer) { 1167 result = ((Integer)o).intValue(); 1168 } 1169 return result; 1170 } 1171 1172 /** 1173 * Sets the SO_RCVBUF option to the specified value for this 1174 * <tt>Socket</tt>. The SO_RCVBUF option is used by the platform's 1175 * networking code as a hint for the size to set 1176 * the underlying network I/O buffers. 1177 * 1178 *
Increasing the receive buffer size can increase the performance of 1179 * network I/O for high-volume connection, while decreasing it can 1180 * help reduce the backlog of incoming data. 1181 * 1182 *
Because SO_RCVBUF is a hint, applications that want to 1183 * verify what size the buffers were set to should call 1184 * {@link #getReceiveBufferSize()}. 1185 * 1186 *
The value of SO_RCVBUF is also used to set the TCP receive window 1187 * that is advertized to the remote peer. Generally, the window size 1188 * can be modified at any time when a socket is connected. However, if 1189 * a receive window larger than 64K is required then this must be requested 1190 * before the socket is connected to the remote peer. There are two 1191 * cases to be aware of:
 1192 *
 1193 *
For sockets accepted from a ServerSocket, this must be done by calling 1194 * {@link ServerSocket#setReceiveBufferSize(int)} before the ServerSocket 1195 * is bound to a local address.

 1196 *
For client sockets, setReceiveBufferSize() must be called before 1197 * connecting the socket to its remote peer.

 1198 * @param size the size to which to set the receive buffer 1199 * size. This value must be greater than 0. 1200 * 1201 * @exception IllegalArgumentException if the value is 0 or is 1202 * negative. 1203 * 1204 * @exception SocketException if there is an error 1205 * in the underlying protocol, such as a TCP error. 1206 * 1207 * @see #getReceiveBufferSize() 1208 * @see ServerSocket#setReceiveBufferSize(int) 1209 * @since 1.2 1210 */ 1211 public synchronized void setReceiveBufferSize(int size) 1212 throws SocketException{ 1213 if (size <= 0) { 1214 throw new IllegalArgumentException("invalid receive size"); 1215 } 1216 if (isClosed()) 1217 throw new SocketException("Socket is closed"); 1218 getImpl().setOption(SocketOptions.SO_RCVBUF, new Integer(size)); 1219 } 1220 1221 /** 1222 * Gets the value of the SO_RCVBUF option for this <tt>Socket</tt>, 1223 * that is the buffer size used by the platform for 1224 * input on this <tt>Socket</tt>. 1225 * 1226 * @return the value of the SO_RCVBUF option for this <tt>Socket</tt>. 1227 * @exception SocketException if there is an error 1228 * in the underlying protocol, such as a TCP error. 1229 * @see #setReceiveBufferSize(int) 1230 * @since 1.2 1231 */ 1232 public synchronized int getReceiveBufferSize() 1233 throws SocketException{ 1234 if (isClosed()) 1235 throw new SocketException("Socket is closed"); 1236 int result = 0; 1237 Object o = getImpl().getOption(SocketOptions.SO_RCVBUF); 1238 if (o instanceof Integer) { 1239 result = ((Integer)o).intValue(); 1240 } 1241 return result; 1242 } 1243 1244 /** 1245 * Enable/disable SO_KEEPALIVE. 1246 * 1247 * @param on whether or not to have socket keep alive turned on. 1248 * @exception SocketException if there is an error 1249 * in the underlying protocol, such as a TCP error. 1250 * @since 1.3 1251 * @see #getKeepAlive() 1252 */ 1253 public void setKeepAlive(boolean on) throws SocketException { 1254 if (isClosed()) 1255 throw new SocketException("Socket is closed"); 1256 getImpl().setOption(SocketOptions.SO_KEEPALIVE, Boolean.valueOf(on)); 1257 } 1258 1259 /** 1260 * Tests if SO_KEEPALIVE is enabled. 1261 * 1262 * @return a boolean indicating whether or not SO_KEEPALIVE is enabled. 1263 * @exception SocketException if there is an error 1264 * in the underlying protocol, such as a TCP error. 1265 * @since 1.3 1266 * @see #setKeepAlive(boolean) 1267 */ 1268 public boolean getKeepAlive() throws SocketException { 1269 if (isClosed()) 1270 throw new SocketException("Socket is closed"); 1271 return ((Boolean) getImpl().getOption(SocketOptions.SO_KEEPALIVE)).booleanValue(); 1272 } 1273 1274 /** 1275 * Sets traffic class or type-of-service octet in the IP 1276 * header for packets sent from this Socket. 1277 * As the underlying network implementation may ignore this 1278 * value applications should consider it a hint. 1279 * 1280 *
 The tc must be in the range  0 <= tc <= 1281 * 255 or an IllegalArgumentException will be thrown. 1282 *
Notes: 1283 *
For Internet Protocol v4 the value consists of an 1284 * integer, the least significant 8 bits of which 1285 * represent the value of the TOS octet in IP packets sent by 1286 * the socket. 1287 * RFC 1349 defines the TOS values as follows: 1288 *
 1289 *
 1290 *
IPTOS_LOWCOST (0x02)
 1291 *
IPTOS_RELIABILITY (0x04)
 1292 *
IPTOS_THROUGHPUT (0x08)
 1293 *
IPTOS_LOWDELAY (0x10)
 1294 *
 1295 * The last low order bit is always ignored as this 1296 * corresponds to the MBZ (must be zero) bit. 1297 *
 1298 * Setting bits in the precedence field may result in a 1299 * SocketException indicating that the operation is not 1300 * permitted. 1301 *
 1302 * As RFC 1122 section <IP_ADDRESS> indicates, a compliant TCP 1303 * implementation should, but is not required to, let application 1304 * change the TOS field during the lifetime of a connection. 1305 * So whether the type-of-service field can be changed after the 1306 * TCP connection has been established depends on the implementation 1307 * in the underlying platform. Applications should not assume that 1308 * they can change the TOS field after the connection. 1309 *
 1310 * For Internet Protocol v6 tc is the value that 1311 * would be placed into the sin6_flowinfo field of the IP header. 1312 * 1313 * @param tc an int value for the bitset. 1314 * @throws SocketException if there is an error setting the 1315 * traffic class or type-of-service 1316 * @since 1.4 1317 * @see #getTrafficClass 1318 */ 1319 public void setTrafficClass(int tc) throws SocketException { 1320 if (tc < 0 || tc > 255) 1321 throw new IllegalArgumentException("tc is not in range 0 -- 255"); 1322 1323 if (isClosed()) 1324 throw new SocketException("Socket is closed"); 1325 getImpl().setOption(SocketOptions.IP_TOS, new Integer(tc)); 1326 } 1327 1328 /** 1329 * Gets traffic class or type-of-service in the IP header 1330 * for packets sent from this Socket 1331 *
 1332 * As the underlying network implementation may ignore the 1333 * traffic class or type-of-service set using {@link #setTrafficClass(int)} 1334 * this method may return a different value than was previously 1335 * set using the {@link #setTrafficClass(int)} method on this Socket. 1336 * 1337 * @return the traffic class or type-of-service already set 1338 * @throws SocketException if there is an error obtaining the 1339 * traffic class or type-of-service value. 1340 * @since 1.4 1341 * @see #setTrafficClass(int) 1342 */ 1343 public int getTrafficClass() throws SocketException { 1344 return ((Integer) (getImpl().getOption(SocketOptions.IP_TOS))).intValue(); 1345 } 1346 1347 /** 1348 * Enable/disable the SO_REUSEADDR socket option. 1349 *
 1350 * When a TCP connection is closed the connection may remain 1351 * in a timeout state for a period of time after the connection 1352 * is closed (typically known as the <tt>TIME_WAIT</tt> state 1353 * or <tt>2MSL</tt> wait state). 1354 * For applications using a well known socket address or port 1355 * it may not be possible to bind a socket to the required 1356 * <tt>SocketAddress</tt> if there is a connection in the 1357 * timeout state involving the socket address or port. 1358 *
 1359 * Enabling <tt>SO_REUSEADDR</tt> prior to binding the socket 1360 * using {@link #bind(SocketAddress)} allows the socket to be 1361 * bound even though a previous connection is in a timeout 1362 * state. 1363 *
 1364 * When a <tt>Socket</tt> is created the initial setting 1365 * of <tt>SO_REUSEADDR</tt> is disabled. 1366 *
 1367 * The behaviour when <tt>SO_REUSEADDR</tt> is enabled or 1368 * disabled after a socket is bound (See {@link #isBound()}) 1369 * is not defined. 1370 * 1371 * @param on whether to enable or disable the socket option 1372 * @exception SocketException if an error occurs enabling or 1373 * disabling the <tt>SO_RESUEADDR</tt> socket option, 1374 * or the socket is closed. 1375 * @since 1.4 1376 * @see #getReuseAddress() 1377 * @see #bind(SocketAddress) 1378 * @see #isClosed() 1379 * @see #isBound() 1380 */ 1381 public void setReuseAddress(boolean on) throws SocketException { 1382 if (isClosed()) 1383 throw new SocketException("Socket is closed"); 1384 getImpl().setOption(SocketOptions.SO_REUSEADDR, Boolean.valueOf(on)); 1385 } 1386 1387 /** 1388 * Tests if SO_REUSEADDR is enabled. 1389 * 1390 * @return a boolean indicating whether or not SO_REUSEADDR is enabled. 1391 * @exception SocketException if there is an error 1392 * in the underlying protocol, such as a TCP error. 1393 * @since 1.4 1394 * @see #setReuseAddress(boolean) 1395 */ 1396 public boolean getReuseAddress() throws SocketException { 1397 if (isClosed()) 1398 throw new SocketException("Socket is closed"); 1399 return ((Boolean) (getImpl().getOption(SocketOptions.SO_REUSEADDR))).booleanValue(); 1400 } 1401 1402 /** 1403 * Closes this socket. 1404 *
 1405 * Any thread currently blocked in an I/O operation upon this socket 1406 * will throw a {@link SocketException}. 1407 *
 1408 * Once a socket has been closed, it is not available for further networking 1409 * use (i.e. can't be reconnected or rebound). A new socket needs to be 1410 * created. 1411 * 1412 *
 Closing this socket will also close the socket's 1413 * {@link java.io.InputStream InputStream} and 1414 * {@link java.io.OutputStream OutputStream}. 1415 * 1416 *
 If this socket has an associated channel then the channel is closed 1417 * as well. 1418 * 1419 * @exception IOException if an I/O error occurs when closing this socket. 1420 * @revised 1.4 1421 * @spec JSR-51 1422 * @see #isClosed 1423 */ 1424 public synchronized void close() throws IOException { 1425 synchronized(closeLock) { 1426 if (isClosed()) 1427 return; 1428 if (created) 1429 impl.close(); 1430 closed = true; 1431 } 1432 } 1433 1434 /** 1435 * Places the input stream for this socket at "end of stream". 1436 * Any data sent to the input stream side of the socket is acknowledged 1437 * and then silently discarded. 1438 *
 1439 * If you read from a socket input stream after invoking 1440 * shutdownInput() on the socket, the stream will return EOF. 1441 * 1442 * @exception IOException if an I/O error occurs when shutting down this 1443 * socket. 1444 * 1445 * @since 1.3 1446 * @see java.net.Socket#shutdownOutput() 1447 * @see java.net.Socket#close() 1448 * @see java.net.Socket#setSoLinger(boolean, int) 1449 * @see #isInputShutdown 1450 */ 1451 public void shutdownInput() throws IOException 1452 { 1453 if (isClosed()) 1454 throw new SocketException("Socket is closed"); 1455 if (!isConnected()) 1456 throw new SocketException("Socket is not connected"); 1457 if (isInputShutdown()) 1458 throw new SocketException("Socket input is already shutdown"); 1459 getImpl().shutdownInput(); 1460 shutIn = true; 1461 } 1462 1463 /** 1464 * Disables the output stream for this socket. 1465 * For a TCP socket, any previously written data will be sent 1466 * followed by TCP's normal connection termination sequence. 1467 * 1468 * If you write to a socket output stream after invoking 1469 * shutdownOutput() on the socket, the stream will throw 1470 * an IOException. 1471 * 1472 * @exception IOException if an I/O error occurs when shutting down this 1473 * socket. 1474 * 1475 * @since 1.3 1476 * @see java.net.Socket#shutdownInput() 1477 * @see java.net.Socket#close() 1478 * @see java.net.Socket#setSoLinger(boolean, int) 1479 * @see #isOutputShutdown 1480 */ 1481 public void shutdownOutput() throws IOException 1482 { 1483 if (isClosed()) 1484 throw new SocketException("Socket is closed"); 1485 if (!isConnected()) 1486 throw new SocketException("Socket is not connected"); 1487 if (isOutputShutdown()) 1488 throw new SocketException("Socket output is already shutdown"); 1489 getImpl().shutdownOutput(); 1490 shutOut = true; 1491 } 1492 1493 /** 1494 * Converts this socket to a String. 1495 * 1496 * @return a string representation of this socket. 1497 */ 1498 public String toString() { 1499 try { 1500 if (isConnected()) 1501 return "Socket[addr=" + getImpl().getInetAddress() + 1502 ",port=" + getImpl().getPort() + 1503 ",localport=" + getImpl().getLocalPort() + "]"; 1504 } catch (SocketException e) { 1505 } 1506 return "Socket[unconnected]"; 1507 } 1508 1509 /** 1510 * Returns the connection state of the socket. 1511 *
 1512 * Note: Closing a socket doesn't clear its connection state, which means 1513 * this method will return true for a closed socket 1514 * (see {@link #isClosed()}) if it was successfuly connected prior 1515 * to being closed. 1516 * 1517 * @return true if the socket was successfuly connected to a server 1518 * @since 1.4 1519 */ 1520 public boolean isConnected() { 1521 // Before 1.3 Sockets were always connected during creation 1522 return connected || oldImpl; 1523 } 1524 1525 /** 1526 * Returns the binding state of the socket. 1527 *
 1528 * Note: Closing a socket doesn't clear its binding state, which means 1529 * this method will return true for a closed socket 1530 * (see {@link #isClosed()}) if it was successfuly bound prior 1531 * to being closed. 1532 * 1533 * @return true if the socket was successfuly bound to an address 1534 * @since 1.4 1535 * @see #bind 1536 */ 1537 public boolean isBound() { 1538 // Before 1.3 Sockets were always bound during creation 1539 return bound || oldImpl; 1540 } 1541 1542 /** 1543 * Returns the closed state of the socket. 1544 * 1545 * @return true if the socket has been closed 1546 * @since 1.4 1547 * @see #close 1548 */ 1549 public boolean isClosed() { 1550 synchronized(closeLock) { 1551 return closed; 1552 } 1553 } 1554 1555 /** 1556 * Returns whether the read-half of the socket connection is closed. 1557 * 1558 * @return true if the input of the socket has been shutdown 1559 * @since 1.4 1560 * @see #shutdownInput 1561 */ 1562 public boolean isInputShutdown() { 1563 return shutIn; 1564 } 1565 1566 /** 1567 * Returns whether the write-half of the socket connection is closed. 1568 * 1569 * @return true if the output of the socket has been shutdown 1570 * @since 1.4 1571 * @see #shutdownOutput 1572 */ 1573 public boolean isOutputShutdown() { 1574 return shutOut; 1575 } 1576 1577 /** 1578 * The factory for all client sockets. 1579 */ 1580 private static SocketImplFactory factory = null; 1581 1582 /** 1583 * Sets the client socket implementation factory for the 1584 * application. The factory can be specified only once. 1585 *
 1586 * When an application creates a new client socket, the socket 1587 * implementation factory's createSocketImpl method is 1588 * called to create the actual socket implementation. 1589 *
 1590 * Passing null to the method is a no-op unless the factory 1591 * was already set. 1592 *
If there is a security manager, this method first calls 1593 * the security manager's checkSetFactory method 1594 * to ensure the operation is allowed. 1595 * This could result in a SecurityException. 1596 * 1597 * @param fac the desired factory. 1598 * @exception IOException if an I/O error occurs when setting the 1599 * socket factory. 1600 * @exception SocketException if the factory is already defined. 1601 * @exception SecurityException if a security manager exists and its 1602 * checkSetFactory method doesn't allow the operation. 1603 * @see java.net.SocketImplFactory#createSocketImpl() 1604 * @see SecurityManager#checkSetFactory 1605 */ 1606 public static synchronized void setSocketImplFactory(SocketImplFactory fac) 1607 throws IOException 1608 { 1609 if (factory != null) { 1610 throw new SocketException("factory already defined"); 1611 } 1612 SecurityManager security = System.getSecurityManager(); 1613 if (security != null) { 1614 security.checkSetFactory(); 1615 } 1616 factory = fac; 1617 } 1618 1619 /** 1620 * Sets performance preferences for this socket. 1621 * 1622 *
 Sockets use the TCP/IP protocol by default. Some implementations 1623 * may offer alternative protocols which have different performance 1624 * characteristics than TCP/IP. This method allows the application to 1625 * express its own preferences as to how these tradeoffs should be made 1626 * when the implementation chooses from the available protocols. 1627 * 1628 *
 Performance preferences are described by three integers 1629 * whose values indicate the relative importance of short connection time, 1630 * low latency, and high bandwidth. The absolute values of the integers 1631 * are irrelevant; in order to choose a protocol the values are simply 1632 * compared, with larger values indicating stronger preferences. Negative 1633 * values represent a lower priority than positive values. If the 1634 * application prefers short connection time over both low latency and high 1635 * bandwidth, for example, then it could invoke this method with the values 1636 * <tt>(1, 0, 0)</tt>. If the application prefers high bandwidth above low 1637 * latency, and low latency above short connection time, then it could 1638 * invoke this method with the values <tt>(0, 1, 2)</tt>. 1639 * 1640 *
 Invoking this method after this socket has been connected 1641 * will have no effect. 1642 * 1643 * @param connectionTime 1644 * An <tt>int</tt> expressing the relative importance of a short 1645 * connection time 1646 * 1647 * @param latency 1648 * An <tt>int</tt> expressing the relative importance of low 1649 * latency 1650 * 1651 * @param bandwidth 1652 * An <tt>int</tt> expressing the relative importance of high 1653 * bandwidth 1654 * 1655 * @since 1.5 1656 */ 1657 public void setPerformancePreferences(int connectionTime, 1658 int latency, 1659 int bandwidth) 1660 { 1661 /* Not implemented yet */ 1662 } 1663 }


"Streams in node are one of the rare occasions when doing something the fast way is actually easier.
SO USE THEM. not since bash has streaming been introduced into a high level language as nicely as it is in node.(*)"
(*) https://gist.github.com/dominictarr/2401787


{% extends 'main/base.html' %} {% load static %} {% block main %}
Github has data about your own repos and commit activity. You can use this website to retrieve and store detailed data from your Github account in your Open Humans account.
Github is a web based hosting service for version control using Git. This website can be used to retrieve and store detailed information about your repos and commit activity in your Open Humans account, in an ongoing manner. Once you add this data to Open Humans, you can choose to share or explore it!
Check out this project's activity page to see how notebooks, projects, and members are using & sharing this data. (Once connected, you can also find your data on this page!)
This site is managed by Open Humans and follows the same terms of use. Data stored in Open Humans is private by default: it's your personal archive and always available to you, and you choose when to share with others.
{% endblock main %}


Logout
Multi-Modal Intelligent Traffic Signal Systems
User Interface
Configuration Manager
Performance Observer
        Hasting - Daisy Mountain Dr. Intersection Configuration:
Is it coordinated?
    Coordination Weight:
0
    Cycle:
    Offset:
    Coordinated Phase:
    Coordinated Phase Split:
Does EV Override?
Priority Weights:
        Truck     0
100

        Transit   0
100

        Truck
50
50
  Transit


The Cryptocurrency network analyzer parses through open source network traffic data on various ports to visualize the traffic in a more digestible manner. This demonstration uses the open source data on IPv4-wide port scans available from Rapid7, an open data community that provides members access to data from Project Sonar which conducts internet-wide surveys to gain insights into global exposure to common vulnerabilities.
Analyzing bitcoin port scans.
Correlating IP addresses to location.
Correlating location with electricity costs.
Analyze geolocation data for bitcoin networks in relation to location specific metrics to reveal trends, and ultimately map popularity of bitcoin locations to characteristics such as profitability over time.
Overview: Bitcoin Usage Broken Down by Country for 2018
Bitcoin Nodes: North America
Bitcoin Nodes: South America
Bitcoin Nodes: Europe
Bitcoin Nodes: Asia
Bitcoin Nodes: Australia
A demonstration has been created that allows you to interactively scroll around the Earth to see locations of network traffic regarding bitcoin activity.This demo was made possible by Rapid7 for providing the open source data and cesium consortium for providing a library to visualize our analysis.The web application allows the user to visualize bitcoin network traffic through a time series. Currently it is limited to only bitcoin, but future iterations of this demo would include scans of other ports. Please enjoy the demo!
DemoThe creators of the demo for this project are Devleena Das, Jonathan Dolan, Joshua Henson, Albert Li, Samantha Mann, and Eric Rafalovsky. All are students at Georgia Tech. This project was developed for ECE 4605, which serves to underline advanced internetworking topics. This project emphasizes the topic of big data.


Some minor updates to the eosgarden's freeware line.
PropEdit has been updated to version 1.0.1:
Download page
ConsoleGrowl has been updated to version 1.2.2:
Download page
No new feature. Those new releases contains only minor bugfixes.


Highway 97 slow down
by John LawlessIf you're travelling on Highway 97 this week you should expect some slow traffic due to maintenance.
The highway will be narrowed down to one lane between 15th & 48th Avenues while crews do some routine storm catch basin cleaning.
Expect some delays between 9 a.m. and 3 p.m. from Nov 26 to Nov 29.


BaccRPC Maker
State:
Detail:
Image Text:
Submit
PLAYING A GAME
BaccRPC Maker
Having a custom RPC
BaccRPC Maker
Status:
The RPC has not been connected, please wait a while till it is loaded...


Welcome to Unity Container Site
Overview
The Unity Container (Unity) is a lightweight, extensible dependency injection container. It facilitates building loosely coupled applications and provides developers with the following advantages:
- Simplified object creation, especially for hierarchical object structures and dependencies
- Abstraction of requirements; this allows developers to specify dependencies at run time or in configuration and simplify management of crosscutting concerns
- Increased flexibility by deferring component configuration to the container
- Service location capability; this allows clients to store or cache the container
- Instance and type interception
- Registration by convention
Issues and Contributions
- If something is broken and you know how to fix it, send a pull request.
- If you have no idea what is wrong, create an issue
Any feedback and contributions are welcome
Roadmap
v4.0.1
Version 4.x is dead. Loss of original signing certificate made it impossible to release anything compatible with v4.0.1 release. To give original developers a credit only about 60 issues were found during two years in production. To move on and enable further development version v5 has been created.
v5.x
Version 5.x is created as replacement for v4.0.1. Assemblies and namespaces are renamed and refactored but otherwise it is compatible with the original. v5.0.0 release fixes most of the issues found in v4.0.1 and implements several optimizations but the accent was on compatibility and if optimization would break API it was ommited. Once stabilized, this version will enter LTS status and will be patched and fixed for the next few years. There will be no significant development in this line.
v6.x
This is where all new development will be done. The plan for next release is:
- Optimize performance
- Add support for Microsoft.Extensions.DependencyInjection.2.0.0
- Improve how constructors and dependencies are selected
- etc.
The compatibilty would not be a driving factor so better performance and functionality could be acheived.
Release schedule and Long Time Support (LTS) 1
| Release | LTS Status | Active LTS Start | Maintenance Start | Maintenance End |
|---|---|---|---|---|
| v3.x | No LTS | - | - | 2012 |
| v4.x | End-of-Life | - | - | 2015 |
| v5.x | Active | 2017-10-18 | October 2017 | December 2019 |
| [6.x] | Pending | 2018-01-01 | January 2018 |
- 1: All scheduled dates are subject to change.


The old version of mcpe.me has been decommissioned and replaced with this website.
You will need to create an account and sign in. Then you can click "Records" and "Create records" in the menu bar. Enter your details and your record will be created instantly.
What you put in "content" depends on your record type, but it should be some way to connect to your server.
 There are plenty of other services that do a great job creating servers and you should try one of those. These services cost money, but that is only logical, running a server does cost money.
Verification is a process which ensures that the record owner is also the server owner. Only MCPE servers can be verified. You may be requested to verify your server by our staff for security reasons.
You can verify a server by setting the title of the server to the "Record ID" and restarting the server. mcpe.me will verify you server a few seconds after you add the server. If your server is confirmed to be an MCPE server (but doesn't have the verification code set), mcpe.me will try again in 20 minutes. You can force mcpe.me to re-verify by submitting the edit form without any changes. Verification is not instant, it will take about 15 second for mcpe.me to complete a verification.
I accept personal donations to my PayPal. You can send money to<EMAIL_ADDRESS>or my using my paypal.me link. If you would like to receive a "donator" rank on mcpe.me, you must add your mcpe.me username in the note.
Donations are primarily used to reimburse the money I pay out of my own pocket to run this service and other MCPE related services. They will also be used to pay for useful things like food and servers for new projects.
The new service generates and uses an array of tokens and key to operate.
User ID - this is a unique identifier for a user that can't be changed. It is useful for reporting users.
Record ID - this is a unique identifier for a record that can't be changed. It is useful for requesting support with records.
CF ID - each record is assigned an ID by CloudFlare. This ID may change over the course of the record's life and is only used internally.
Record API key - each record has a key generated for performing remote updates on it. This key is not yet used.


Options:
Show guides
Check identical X axis only (
sameX
)
Check identical Y axis only (
sameY
)
Tolerance (in pixels):
1
Legend:
Nearest to cursor (found two ways)
Furthest from cursor
Nearest to clicked element
Furthest from clicked element
Tolerance for nearest element
Tolerance for furthest element
Back to documentation


Rattlesnakes live in the desert. They eat rats. They are cold blooded.
What snakes eat
Where snakes live


|
"Official" POD-Bot Pages:
http://www.nuclearbox.com/podbot/
http://www.botepidemic.com/podbot/
Forum:
http://www.nuclearbox.com/ubb/cgi-bin/ultimatebb.cgi?ubb=forum&f=15
My Personal Homepage (abandoned for some time now):
http://www.geocities.com/countfloyd_1999/
This Bot has been started based on code from the Half-Life HPB-Bot by
Botman. It has evolved over the time and this is the result...anyway,
thanks again Botman !
Credits
Bot Coding: Count Floyd
Installer: Polymorph & Count Floyd (using the Vise
Installer)
Waypoints: TAZ (most), Bot_Guy, Count Floyd
GFX: runab0ut & Fade1
Copyright and Distribution Permissions
The Bot included in this archive is Copyright © 2000,2001
Markus Klinge aka Count Floyd.
The Bot may only be distributed if this file and all the other files
that came with it are included in the redistribution, and no money is
charged for the product being distributed. This excludes such things
as video game magazines which include a CD and things such as that,
which are
permitted to include this bot (provided they meet the requirements above)
as long as they notify me before doing so and get my permission through
e-mail or some other form.
Disclaimer
Software under this agreement is under no kind of warranty. Software
under this agreement is provided as is, and isn't guaranteed in any
way by the Bot author. Use this software at your own risk !
Requirements:
The Bot currently works with Counter-Strike Beta 6.5 - 7.1 and
CS 1.0 to newest version (with both Retail & normal version).
If you're not using the CounterStrike Retail Version, Half-Life version
<IP_ADDRESS> or higher is required to use this bot. If you haven't updated
your Half-Life version to <IP_ADDRESS> (or higher)
you will HAVE to do so before using it.
Windows Installation:
The installation process is now handled by the supplied Installer.
Linux Installation:
Linux Version not available yet.
If you want to use translated versions of the Botchat, these files
are available
right now:
- BotChat.txt (default english version)
- BotChatBulgarian.txt
- BotChatCroatian.txt
- BotChatCzech.txt
- BotChatDanish.txt
- BotChatDutch.txt
- BotChatEnglish.txt
- BotChatFinnish.txt
- BotChatFrench.txt
- BotChatGerman.txt
- BotChatHungarian.txt
- BotChatIceland.txt
- BotChatIndonesian.txt
- BotChatItalian.txt
- BotChatNorwegian.txt
- BotChatPolish.txt
- BotChatPortuguese.txt
- BotChatRomanian.txt
- BotChatRussian.txt
- BotChatSerbian.txt
- BotChatSpanish.txt
- BotChatSwedish.txt
- BotChatTagalog.txt
- BotChatTurkish.txt
all located in the Podbot\Botchats Folder where you installed the Bot.
Rename and copy one of these to "botchat.txt" in the
main podbot folder to have your localized Bot Talk...
Note that the translated versions (except the german & english ones)
don't use the new Text replacements and the dynamic keyword chat is
still in english language.
Also located in the main folder is a File called botskill.cfg
were you can tweak most skill
settings for the Bots if you find them too easy/too hard, to change
the Names Bots use just edit Botnames.txt and some useful settings
can be changed in podbot.cfg.
Now you're ready to play!
Removing the Bot from your system (Windows)
Just use the 'Remove POD-Bot' ShortCut in your Start-Menu. After that
you have to rename the file 'csold.gam' to 'liblist.gam' in your cstrike
Game Folder to have a full working CS again.
How to start a Game with Bots:
Create a Game with a map that has waypoints for POD-Bot (take a look
into
the "cstrike\podbot\WPTDefault" folder - all files with the
extension ".pwf"
should be valid waypoint files.
Bots will automatically be added to the game using the "podbot.cfg"
file found
in the /cstrike/podbot directory. If you wish to change the number of
bots
that are created automatically you can edit the podbot.cfg file
using any text editor.
Since V1.4 a helpful User Menu is available for performing the most
used actions.
It's bound by default (you can change it in podbot.cfg) to the
"=" key. If you're
pressing the "=" key a Menu with the following options should
appear on your Screen:
1. Quick Add Bot
This does what it says. It quickly adds a Bot giving him a random name,
team, skill
and model. Skill will be chosen randomly between your minbotskill/maxbotskill
values specified in podbot.cfg..
2. Add specific Bot
Allows you specify all things for adding a single Bot.
3. Kill all Bots
Kills all Bots in all Teams. You can use this to end Rounds faster
if there aren't any humans alive and you don't like watching Bots playing
better than you :)
4. Newround
Same as above, but kills every Client including human players.
5. Fill Server with Bots
Fills all free Server Entries with Bots. After selecting this option
you can specify the team or to auto-assign them. If you especially select
a team for the Bots the Server Variables "mp_autoteambalance"
and "mp_limitteams" will be set to 0 (thus not caring about
balancing teams anymore) and all Bots will only join 1 Team. You can
use for example this to play alone or with your friends against all
Bots.
6. Kick Random Bot
Kicks the first Bot in the List.
7. Remove all Bots
Kicks all Bots off the Server.
8. Select Weapon Mode
Opens another Sub-Menu where you can select the Weapons Bots will buy
(and use in combat). Selecting Knife Mode will also turn on Jason-Mode.
Selecting Standard Weapons will turn it off again.
Using Commands besides the in-game menu (using the console):
If a map has loaded, press the key below "Esc" (the ~ key)
and the console screen scrolls down. Now you're able to type in commands
like the ones used to control POD-Bot.
Some examples:
Just type "addbot" and a new Bot will be connected...
If the Bots are stuck or you just want to start a new round type in
"killbots" which will force all bots to be dead instantly.
If you're sick of
playing with Bots type "removebots" which will kick
all Bots from the Server.
NOTE that this will also set the min_bots & max_bots settings from
the podbot.cfg to zero, so you have to add Bots manually if you want
them back in your game. Of course you can always use "kick"
to remove single bots. To manually change maps, use the substitution
for the map command. Type "newmap mapname" to change
to another map. So for example
to load "DE_DUST" you type "newmap DE_DUST". Bots
present will join the Game
if the map is loaded. For all console commands please read the summary
below...
Summary of Console Commands:
Most of the time you will only need the POD-Bot User Menu which
is by default bound to the "=" key. You can change this easily
with any text-editor in 'podbot.cfg'. All commands in square
[] brackets are optional and don't need to be specified. Most of these
commands will also work in podbot.cfg. Again, PLEASE TAKE A LOOK INTO
THE FILE "podbot.cfg" !
addbot [skill] [team] [name]
Adds a new Bot with skill (0-100) to team (0-1 or use 5 to auto-assign)
with the
specified name. If you don't use the name argument it will be filled
randomly
from "podbot\botnames.txt". You can edit this file
to use other names !
botchat on|off
Turns chatting Bots on or off
botsvotemap x
Orders all dead Bots to vote for Map x, where x is a valid number
of a map in your mapcycle.
imaborg on|off
Let's the Bot AI take care about the (Host) Player. Doesn't work perfectly
yet, use with
caution !
jasonmode on|off
Turns on/off "JasonMode". In this Mode, Bots are only allowed
to use
a Knife and they won't buy any weapons at all. Use this for example
in cs_estate or cs_office to have a scary blood-feast ! This is a
Fun Mode and not to be taken serious ! Kids, don't try this at
home :)
killbots
Does what it says.
newmap mapname
Substitution for the "map" command you're used to. Loads
a new map.
This will work 100% with Bots and no client shouldl get disconnected.
podbotmenu
Displays the User-Menu by default bound to the "=" key.
removebots
Kicks all Bots of the Server. Note that this also changes the
min_bots and max_bots variables to 0.
wptfolder foldername
Specifies the Folder for loading waypoints. No special chars like
Spaces or quotation marks are allowed. Also note that the Folder
must be inside the Podbot Directory and thus the name ONLY consists
of the folder name.
There are also some additional Fun-Modes which can be activated
with these commands:
omg imonmars
Halfs the normal CS Gravity, meaning you can jump a lot higher than
normally and you don't get much damage when falling.  Quite useful on very dark
maps to spot Bots easier.
omg itsnewyear
Bots celebrate New Year ! :)
omg tronisback
Adds a shiny hull over each Player which reminded me of the old movie
"Tron". T Bots are Red, CT Bots are blue.
omg imstoned
You don't want to know... ;)
omg imsober
Turns off all Fun-Modes.
NOTE:
These Fun Modes weren't fully tested out by me and it might be that
this or that isn't working properly with them. They are just leftovers
of my HL Engine tests and were left in to give you (hopefully) a good
laugh. If something doesn't work with them I honestly don't care that
much.
There are some more commands which are only used in
"podbot\podbot.cfg". Please have a look there, too !
A lot of additional console commands are only used for
waypointing. These are explained in a separate File called
WaypointsHowToDo.html
Running POD-Bot on Win32 Dedicated servers:
Install POD-Bot as described above and create a game the way you normally
would.
When running a dedicated server the POD-Bot commands that are normally
available in the client console are disabled. To create a bot you
must set the CVAR "pb" to the command you desire.. To use
the "pb" CVAR you
would use one of the following commands on the dedicated server command
line...
pb "addbot"
pb "addbot 100 5"
pb "addbot 20 1 DumbAss"
In addition these commands are supported:
pb "fillserver 5" (Fills server with auto-assigned Bots)
pb "fillserver 1" (Fills server with Terrorist Bots)
pb "fillserver 2" (Fills server with Counter Bots)
pb "removebots" (Disconnects all Bots from the Game)
pb "killbots" (Kills all Bots in the current round)
pb "newmap mapname" (Changes the Map)
When using the dedicated server, bot will also be automatically spawned
using
the podbot.cfg file. You can also use the min_bots/max_bots settings
or the
addbot command explained in that file.
Playing with the Bots:
The Bots will automatically know the goals of the map. Counter might
go for hostages, Terrorists may want to plant the bomb. VIP Bots will
try to reach the Rescue Points. The goal selection is done dynamically
and will be affected by several factors like Personality, Health, Team-mates
near & Items the Bot is carrying. The Bots will also try to support
team-mates and take cover when they think it's needed.
Ordering Bots through Radio Commands:
You can use some of the Radio Commands to get more support from your
Bots.
The first is "Follow Me" which commands Bots in the
near to follow you.
You can specify the maximum of following Bots in the podbot.cfg File
(defaults to 3).
If a Bot is following you, you can use
"Hold this Position" to make a pause at that Place and look
around for
enemies. You can use "Go,go,go!" to stop him from following
you again.
Note that they won't follow you in 3 cases:
- They don't want to ! The Bots have their own will and they issue
a
"Negative" if they don't want to follow you.
- They don't see you.
- They see an enemy and engage the target.
A Terrorist Bot carrying the C4 or picking it up, will also issue a
"Follow Me" sometimes to have some assistance with him. Note
that
they have problems following on ladders at the moment because the movement
is unwaypointed.
They also do some other Radio Commands like "Need Backup","Enemy
down",
"Enemy spotted","I'm in Position" (to tell you he's
camping) but not very often, otherwise it would surely get on your nerves...
Summary of Bot Reactions to Radio Commands:
Follow me - Forces Bots in the near to follow you
Hold this Position - Makes a Bot who's following you, stay awhile
at that position
Taking Fire, need assistance - Makes all living Bots (not engaged
in a Fight) run to
your position to assist you.
Need Backup - Basically the same as above, but limited to distance
and also the Bots
use it sometimes to get some support.
Storm the Front! - Mighty command! Forces all Bots in the near
to rush in the
direction you're pointing to when using that command. Basically their
level of agression is increased so a pathetic frightened Bot could also
turn around and flee.
Get in position... - Bots in the near will try to take a covered
position and stay there until they either encounter an enemy, you order
them to leave, or they waited too long.
Go,go,go - If a Bot follows you, this commands stops him from
following. If there
are other Bots in the near, they will stop camping and going to roam
the
map again (normally used in combination with "Get in position...")
Team, Fall Back! - Opposite of "Storm the Front".
Increases Fear and decreases agression of Bots in the near so that they
are more likely to fall back and stay covered for a short period.
Bot Skill differences:
First, Bots with low skills will pause/camp longer and more often.
Bots
with low skills have a bigger surprise time and they shoot slower. Bots
with low skill are lucky if they hit something. Then there are minor
behaviour differences. For example Bots with a skill above 80 use the
knife more often if you're near them. If you want to get headshots all
the time (and really fast) add some Bots with a skill of 100.
You can easily change a lot of skill parameters by editing the file
'botskill.cfg' with any text-editor. Also take a look into 'podbot.cfg'
to adjust some more things to your liking...
Bot Personalities:
There are 3 different Personalities in POD now, if you have detailnames
turned on they can are shown through the Prefixes like this:
[P*D] - Agressive
[POD] - Normal
[P0D] - Defensive
Right now the Personality is randomly chosen if a new Bot gets created.
I want to extend a lot of stuff around Personalities so there's no sense
in a specific selection and it can't be done.
Version History:
V2.5 Release Date: 19/08/2001
+ FIXED: Ignoring of the BotSpray Variable
+ FIXED: Wrong Gravity after turning off Fun-Modes
+ FIXED: Having 2 skills when minbotskill = maxbotskill
+ FIXED: Getting the Enemy instantly when being shot
+ FIXED: Nasty Bug in the firing Routine which messed up Reaction Times
& kept Bots from shooting sometimes
+ FIXED: Resetting time to reach when being stuck causing Bots remaining
stuck & doing unnecessary jumps
+ FIXED: CT Bomb Spot Selection when using Experience Files
+ FIXED: Bugs & Problems with linked Lists, causing Memory Leaks
and random crashes
+ FIXED: Bots tracking Enemies through Obstacles when camping/hiding
+ FIXED: All Turns/Movements Frame Independant
+ FIXED: Bugs in weapon buying on AS Maps
+ FIXED: First Bot on dedicated Server not moving properly
+ FIXED: Team mismatch when collecting experience
+ FIXED: Para/SG550 buying Bug when weapon restriction on
+ FIXED: Not dropping primary weapon for new one on the ground in extreme
situations
+ Optimized Player Avoidance a bit
+ Major Rewrite of the debugging core
+ Complete rewritten Burst Firing, now includes non-automatic weapons
and distance to target
+ Extended Hearing code to include Sounds like Opening Doors, Ladders
and a lot more (thanks killaruna!)
+ Added some more dynamic Symbols to the Chatsystem and a 'Name Humanizer'
+ Extended Chatsystem to have Bots Reply to user customizeable Keywords
+ Bots chat with each other when spectating (heavily inspired by ParaBot
from killaruna again!)
+ Smarter Grenade Usage. Bots try to surprise enemies and cancel grenading
if they think it won't succeed
+ Movement now pretty much point precise
+ Changed Bot DS CVAR and some other stuff to be more compatible to
Botmaster5000
+ Ladder climbing should now handle even difficult stuff
+ Added Bot Weapon Mode Menu
+ Removed Bugs in the Aiming Code
+ Added "waypoint teleport"
+ Redid Bot Task/Schedule System resulting in more careful Bots etc.
+ All Radios Commands from 1.4x work again like "GetInPosition..."
+ Bots defend the planted Bomb and the guy who's defusing
+ CT Bots "hear" the planted Bomb
+ Increased Shooting Precision when using zoomed Sniper Weapon
+ Each Team selects a Leader Bot which issues some basic Radio Orders
V2.0 Release Date: 05/06/2001
+ FIXED: Bots trying to pickup things already picked up before
+ FIXED: Ignoring of the MAXFOLLOW Variable
+ FIXED: Radio Commands not working in dedicated Server Mode
+ FIXED: Crash when deleting Waypoint Nr. 0
+ FIXED: Waypoints & Path Connections not displayed after Map Change
+ FIXED: Dedicated Server Commands not working after Mapchange
+ FIXED: Previously broken Covered Movement
+ FIXED: Previously broken hearing of Shoot & Usage Noises
+ FIXED: Freezetime 100% working
+ FIXED: Correct Movement Speeds also in zoomed Mode
+ FIXED: Weapon Buying in AS Maps
+ FIXED: Low/High Angles Aiming Bug
+ FIXED: Included up/down looking at campwaypoints, which was present
since V1.0 but overseen
+ FIXED: Better Detection of Killer Entity
+ FIXED: Diving Problems when swimming
+ FIXED: Stupid Angle Bug which messed up movement sometimes
+ FIXED: Bots try to avoid shooting TeamMates (doesn't apply for bad
Grenading)
+ FIXED: Bots can't be added if Waypoints not initialised
Redid all the find routines
Better Edge Avoidance
Added Bots picking up weapons on the ground (adjustable through BotWeapons.cfg)
Buying can be customised & personalized in BotWeapons.cfg
Added some Teamchat Messages (Bots using Hostages etc.)
Optimized Waypoint Selection Code (much faster!)
Made Waypoint Selection more Team and Map dependant
Bots use SmokeGrenades and are primitively affected
Redid the whole Movement Code. Bots are now able to move backwards/sidewards
while moving to a goal and still check for obstacles in their way
Smarter Combat Strafing/Jumping
Bots now have a small Task-driven Memory
Bots buy all Items (except senseless Nightvision Goggles)
Better enemy detection (more CPU consuming)
Added 3 basic Bot Personalities with adjustable Weapon Preferences
Bots above Skill 80 try to shoot seen/heard Enemies through Obstacles
if possible and enabled in Config
Counter Bots share a global memory of visited Bombspots
Bots on same Team share Enemy Knowledge if they see each other
Bots collect Map Experience about Danger Spots (can be turned off)
Bots primitively use Buttons of all types (except cameras)
Changed Inner Workings of Decision Logic
Hearing Sensibility now affected by Movement Speed & own Noises
Bots shoot back (randomly) at teammates who tried shooting them
Added some Performance Settings to podbot.cfg
Added some more useful console commands for configuring
and helping when waypointing/debugging
Again better Player Avoidance & Unstuck Code
Using the original HL Engine Speech Synthesis to speak to the Host
Added custom Compress/Decompress Routines for those otherwise much too
big Experience Files
Better blinded (Flashbang) Bevahiour
Bots don't loose their leader when seeing Enemies
Improved ladder climbing
Bots shoot at dying enemies (Time based on Agression) if they don't
have a new opponent
CT Bots communicate about visited Bombspots. Humans can use "Sector
clear" to tell them about a visited Bombspot too.
Bots pickup things like Bomb or Weapons while following User
Some improvements & fixes to the waypoint editor
Added Bot Model Selection
Added preemptive Firing (based on Agression & skill) to Fleeing/Hunting
States
Bots can be allowed to vote against disruptive Players
Bots can be ordered (by the host) to vote for a map
Bots Emotions/Desires are also affected by number of teammates near
and current weapon
Some additional Fun-Modes included
Bot Agressions are affected by Roundtime & Team Goals
Waypoint Type Selection now bound to Personality + Agression/Fear +
Team
Failed/Succesful Plans are remembered for each Team and stored in the
experience files (if not turned off by User)
Bots mostly try to get away from Grenades thrown at them
Bots spray Logos (can be customized & turned off)
Bots now use the correct PVS & PAS
V1.4x Release Date: 23/12/2000
+ FIXED: Dedicated Server commands not working after "newmap"
+ FIXED: Bots not shooting when enemy elevation </> than 45 degree
+ FIXED: Bots responding too fast to Radio Commands
+ Added fillserver command to DS commands
+ Recoded the Radio Capturing/Usage (faster & more reliable)
+ Bots react on many radio commands
+ Added much better Player Avoidance Code
+ Bots don't pause until they've seen an enemy
+ Updated FAQ & Readme (make sure to read them!)
+ Added the previously missing de_foption wpt file
+ Added some more localized Botchat translations
+ New podbot.cfg command "botsfollowuser"
V1.4c Release Date: 12/12/2000
+ FIXED: Bots don't going mad anymore when flashbanged
+ FIXED: Hearing Bug when hiding
+ FIXED: Fixed some Issues with Weapon Kickback
+ FIXED: Bots keep ducking when seeing an enemy
+ Added Minimum Turn Amount
+ Added Noclip Option for Waypoint Editing
+ Added Terrorist Bots use Hostages under certain conditions
+ Implemented Proper Sniper Zooming
+ Increased number of "special" waypoints from 32 to 64
+ Added some more dedicated Server Commands
+ Added option to turn on old (1.2) combat behaviour
+ Added botskill.cfg to tweak all skills to your needs
V1.4 Release Date: 9/12/2000
+ FIXED: Bunny Hopping of Snipers
+ FIXED: Crash when adding Bots
+ FIXED: BotChat Freeze on Win2K (Couldn't test this!)
+ FIXED: Humanlike Combat Turning Speed
+ FIXED: Several Bugs in Waypoint Editor
+ FIXED: Living Bots talking to the Dead
+ FIXED: Only Host can issue commands
+ FIXED: Freezetime (first Round) Bug
+ FIXED: Knife being used when Enemy out of range
+ FIXED: Bot Chat Spamming
+ FIXED: Bug in detecting Hostages
+ Rewrote/optimized the Hearing Code
+ Bots now hear Shots and Button Usage within their range
+ Bots randomly use secondary knife mode
+ Changed Waypoint Movement
+ Changes in Basic Movement
+ Changed Waypoint Format
+ Added some stuff to the waypoint editor
+ Added Camp Flags to the Editor
+ Bots above Skill 60 try to stay more covered when moving
+ Improved Ladder climbing up
+ Added Bot User Menu
+ Tweaked Reaction Time again
+ Improved Enemy Detection Handling
+ Bots use Zoom Mode when sniping most of the time
+ Bots Hiding Behaviour improved
+ Added a bunch of new commands to the Config File
+ Added Randomness to Reaction Times
+ Bots are able to swim now
+ Updated/Replaced all Waypoint Files
V1.2 Release Date: 10/11/2000
+ Fully compatible to CounterStrike 1.0 final
+ Bots buy/use all new weapons
+ Recoded all Reaction Routines
+ Burst Fire implemented
+ Smarter Grenade Use/Throwing
+ Tweaked Hunting/Fleeing AI
+ Bots try to hide (not fully implemented)
V1.1 Release Date: 4/11/2000
+ Fixed Weapon dependent Player speeds
+ Fixed VIP Speed
+ Changed Damage Detection Code
+ Fixed Weapon Kickback
+ Implemented hearing Footsteps
+ Modified Sniper Combat behaviour
+ Added Menu-driven Waypoint setting for
Users who want to support own maps
+ Added "Jason-Mode" for people who like
to fight only with knifes
+ Added new Radio Command Reaction:
"Taking Fire..."
+ Bots above Skill 70 sneak if a near Enemy is suspected
+ some minor bug fixes
V1.0 Release Date: 27/10/2000
* First public Release *
Known Limitations/Bugs/Problems still present:
- Bots sometimes fall from high places
- Sometimes stuck in other Bots (but should unstuck after less than
5 secs)
- Sometimes stuck in corners (see above)
- Counter Bots sometimes fail to detect the bomb (but happens to
humans also, so what?)
- "map" command causes crashes sometimes (use "newmap"
instead)
- Due to missing waypoint files only some maps (but all official
ones for CS 1.1!)
supported. You can add your own by making waypoint files yourself!
- Bots don't know how to reason about Buttons/Lifts (but they use
them randomly)
- Bots lack advanced teamplay (very basic team-play and affection
is present)
- Bad covering of Bots sometimes because of no real visibility information
yet
- Bots are too easy to snipe, see above
- No tactical/terrain based pathfinding yet
- Bots aren't affected by darkness
- Bots don't drive Vehicles
- Due to HL Engine Limitations Bots can see through func_illusionaries
(e.g. curtains in cs_747, doors in cs_backalley)
- Bots don't cheat :)
Planned for future Releases:
- Pathfinding which reasons about teams, tactical positions and terrain
- Refining Combat Behaviours and Weapon Choices
- Customisation of Personalities incorporated into a Clan-System
- Advanced Team Behaviour
- Reasoning about Triggered Targets like Doors & Lifts
- Automating the waypointing process
- Vehicle support (hmm, not really!)
- Elimination of most remaining Bugs & Limitations of the above
list
I would like to thank & send out greetings to the following people:
- Botman
(for all his Information, Sources & Templates, without them, this
Bot probably wouldn't exist). Visit his Site:
http://www.planethalflife.com/botman/
- William van der Sterren
(for being always helpful, all the collected info in Botman's Forum
& his own WebSite and interesting e-mail discussions. Check out
his CGF Bots for Action
Quake 2, they are awesome!
- Tobias Heimann (killaruna) for interesting discussions &
ideas and for coding the best Deathmatch Bot so far to my knowledge
- the brilliant ParaBot
- My brother Polymorph for his beta-testing, patience with
me and now doing the Setup for POD. Have a look at his MOD for Half-Life
called 'Kriegshammer'
- Auxois & Smok3 for hosting/supporting me as much as
they can
- Bluesman for being a good moderator & betatester and
being always helpful all in one
- TAZ for supporting me with good waypoints and beta-testing
- Bot_Guy for caring about waypointing too
- runab0ut for investing so much time in doing the Design &
GFX for the 2nd POD Page
- Fairus for running the Community Site
- zeO of BotEpidemic
for hosting me
- Another1 for a short but interesting mail a long time ago
and for allowing me to have a look at his KyBot
- Chris for Betatesting
- all other Bot Authors for inspiring me & being such
a nice
Community (mostly)
- All people who sent contributions for the POD Logo-Contest, especially
runab0ut, Fade1, God and Fairus.
- Kangaroo for being the first one who ever posted into the
POD forum and helping out many people
- The Half-Life & Counter-Strike Developers for creating
such great
games !
- YOU! (for trying out Pod-Bot and reading through the whole
readme)
- everybody else I missed in this list ...
If you still have questions, be sure to read
FAQ.html. Your question might already be answered
there. If not please use the POD-Bot forum here:
http://www.nuclearbox.com/ubb/cgi-bin/ultimatebb.cgi?ubb=forum&f=15
If this still doesn't help you you can mail me at<EMAIL_ADDRESS>(please don't mail me suggestions or your personal wishlist, use the
Forum instead !)
AND DON'T ASK ME FOR RELEASE DATES OF FUTURE VERSIONS, SUCH E-MAILS
WILL BE DELETED AT ONCE!
And now don't waste time reading, waste some Bots instead ! Enjoy
!
|


Can't see this email?
Click here
Reset Your Password
Reset Your Password
You requested to reset your password for your Wix account.
You requested to reset your
password for your Wix account.
Reset Password
Questions? Contact
Wix Support
.
If you did not request to reset your password,
please ignore this email.
Reset Password
Questions? Contact
Wix Support
.
If you did not request to reset your password, please ignore this email.
Please do not reply to this email
500 Terry A Francois Blvd San Francisco, CA 94158
View our
privacy policy


| 1 | package fr.sii.ogham.core.util.bean; | |
| 2 | ||
| 3 | /** | |
| 4 | * Implementation that is used by default by | |
| 5 | * {@link RecursiveBeanReadWrapper} in order to wrap nested beans. | |
| 6 | * | |
| 7 | * @author Aurélien Baudet | |
| 8 | * | |
| 9 | */ | |
| 10 | public class DefaultRecursiveBeanReadWrapperFactory implements BeanReadWrapperFactory { | |
| 11 | ||
| 12 | @Override | |
| 13 | public BeanReadWrapper create(Object bean) { | |
| 14 |
2
1. create : All method instructions replaced by: return null; → NO_COVERAGE 2. create : All method instructions replaced by: return null; → KILLED |
return new RecursiveBeanReadWrapper(new SimpleBeanReadWrapper(bean)); |
| 15 | } | |
| 16 | ||
| 17 | } | |
Mutations | ||
| 14 |
1.1 2.2 |


Documentation
Getting Started
Authentication
Errors
APIs
/catalogs
/catalog/:id
/catalog/:id/packages
/packages/:id
/books
/books
/books/:id
/books/:id
/books/:id
Template by CloudCannon
Search Results
Loading
results
for "
"