Code example for Socket

Methods: connect, getInputStream, getOutputStream, setSoTimeout

0
     * @param addr 
     * @return Transport instance 
     * @throws IOException  
     */ 
    public static Transport TCPInstance(SocketAddress addr) throws IOException {
        Socket sock = new Socket();
        sock.setSoTimeout(getTimeout());
        sock.connect(addr);
 
        StreamTransport trans = new StreamTransport();
        trans.setStreams(sock.getInputStream(), sock.getOutputStream());
        trans.setAddressLabel(addr.toString());
        return trans;
    } 
 
    private static int getTimeout() { 
        return 500; 
    } 
 
    /** 
     * Returns new UDP Transport instance