<commit_before>package test.direct.splice;

import ibis.connect.direct.DirectServerSocket;
import ibis.connect.direct.DirectSocket;
import ibis.connect.direct.DirectSocketFactory;
import ibis.connect.direct.SocketAddressSet;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.SocketAddress;

public class SpliceTest {

    private static final int LOCAL_PORT = 16889;
    
    public static void main(String [] args) throws IOException { 
        
        DirectSocketFactory sf = DirectSocketFactory.getSocketFactory();
        
        if (args.length > 0) {
 
            SocketAddressSet target = new SocketAddressSet(args[0]);
           
            for (int i=0;i<100;i++) {
                try { 
                    DirectSocket s = sf.createSocket(target, 0, LOCAL_PORT, null);
                
                    System.out.println("Created connection to " + target + 
                            " on local address " + s.getLocalSocketAddress() 
                            + " remote address " + s.getRemoteSocketAddress());

                    DataInputStream in = new DataInputStream(s.getInputStream());
                    DataOutputStream out = new DataOutputStream(s.getOutputStream());

                    out.writeUTF("Hello server!");
                    out.flush();
                
                    System.out.println("Server says: " + in.readUTF());

                    DirectSocketFactory.close(s, out, in);
                } catch (Exception e) {
                    System.out.println("Failed to created connection to " 
                            + target);
                }
            }
        } else {                         
            System.out.println("Creating server socket");
            
            DirectServerSocket ss = sf.createServerSocket(LOCAL_PORT, 0, null);
            ss.setReuseAddress(true);
            
            System.out.println("Created server on " + ss.getAddressSet());

            // Get a normal connection first...            
            DirectSocket s = ss.accept();
          
            InetSocketAddress address = 
                (InetSocketAddress) s.getRemoteSocketAddress();

            System.out.println("Incoming connection from " + address); 
            
            DataInputStream in = new DataInputStream(s.getInputStream());
            DataOutputStream out = new DataOutputStream(s.getOutputStream());
            
            System.out.println("Client says: " + in.readUTF());
            out.writeUTF("Hello client!");
            out.flush();
            
            DirectSocketFactory.close(s, out, in);

            // Now try if we can connect to the client using an outgoing 
            // connection

            SocketAddressSet target = new SocketAddressSet(address);
            
            for (int i=0;i<100;i++) {

                try { 
                    s = sf.createSocket(target, 0, LOCAL_PORT, null);
            
                    System.out.println("Created connection to " + target + 
                            " on local address " + s.getLocalSocketAddress() 
                            + " remote address " + s.getRemoteSocketAddress());

                    in = new DataInputStream(s.getInputStream());
                    out = new DataOutputStream(s.getOutputStream());

                    out.writeUTF("Hello server!");
                    out.flush();
            
                    System.out.println("Server says: " + in.readUTF());

                    DirectSocketFactory.close(s, out, in);
                } catch (Exception e) {
                    System.out.println("Failed to created connection to " 
                            + target); 
                }
            }
        }
    }
}<commit_msg>-- partial<commit_after>package test.direct.splice;

import ibis.connect.direct.DirectServerSocket;
import ibis.connect.direct.DirectSocket;
import ibis.connect.direct.DirectSocketFactory;
import ibis.connect.direct.SocketAddressSet;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.InetSocketAddress;

public class SpliceTest {

    private static final int LOCAL_PORT = 16889;
    
    public static void main(String [] args) throws IOException { 
        
        DirectSocketFactory sf = DirectSocketFactory.getSocketFactory();
        
        if (args.length > 0) {
 
            SocketAddressSet target = new SocketAddressSet(args[0]);
           
            DirectSocket s = null;
            DataInputStream in = null;
            DataOutputStream out = null;
            
            for (int i=0;i<100;i++) {
                try { 
                    s = sf.createSocket(target, 0, LOCAL_PORT, null);
                
                    System.out.println("Created connection to " + target + 
                            " on local address " + s.getLocalSocketAddress() 
                            + " remote address " + s.getRemoteSocketAddress());

                    in = new DataInputStream(s.getInputStream());
                    out = new DataOutputStream(s.getOutputStream());

                    out.writeUTF("Hello server!");
                    out.flush();
                
                    System.out.println("Server says: " + in.readUTF());

                } catch (Exception e) {
                    System.out.println("Failed to created connection to " 
                            + target);
                } finally { 
                    DirectSocketFactory.close(s, out, in);
                }
            }
        } else {                         
            System.out.println("Creating server socket");
            
            DirectServerSocket ss = sf.createServerSocket(LOCAL_PORT, 0, null);
            ss.setReuseAddress(true);
            
            System.out.println("Created server on " + ss.getAddressSet());

            // Get a normal connection first...            
            DirectSocket s = ss.accept();
          
            InetSocketAddress address = 
                (InetSocketAddress) s.getRemoteSocketAddress();

            System.out.println("Incoming connection from " + address); 
            
            DataInputStream in = new DataInputStream(s.getInputStream());
            DataOutputStream out = new DataOutputStream(s.getOutputStream());
            
            System.out.println("Client says: " + in.readUTF());
            out.writeUTF("Hello client!");
            out.flush();
            
            DirectSocketFactory.close(s, out, in);

            // Now try if we can connect to the client using an outgoing 
            // connection

            SocketAddressSet target = new SocketAddressSet(address);
            
            for (int i=0;i<100;i++) {

                try { 
                    s = sf.createSocket(target, 0, LOCAL_PORT, null);
            
                    System.out.println("Created connection to " + target + 
                            " on local address " + s.getLocalSocketAddress() 
                            + " remote address " + s.getRemoteSocketAddress());

                    in = new DataInputStream(s.getInputStream());
                    out = new DataOutputStream(s.getOutputStream());

                    out.writeUTF("Hello server!");
                    out.flush();
            
                    System.out.println("Server says: " + in.readUTF());
                  
                } catch (Exception e) {
                    System.out.println("Failed to created connection to " 
                            + target); 
                } finally { 
                    DirectSocketFactory.close(s, out, in);
                }
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.09443808069237622, 'fraction_numerical': 0.004581901489117984, 'mean_word_length': 1.4298082869511441, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '511155', 'n_tokens_mistral': 1919, 'n_tokens_neox': 1773, 'n_words': 411}