@Override
        protected Integer doInBackground() throws Exception {
            /* Try to connect to the server on localhost, port 5556 */
            jLabel3.setText("Sending transfer command");
            ChatBox.MultiThreadChatClient.os.println("/send");
            Socket sk = new Socket("188.26.255.139", 5557);
            OutputStream output = sk.getOutputStream();
            
            OutputStreamWriter outputStream = new OutputStreamWriter(sk.getOutputStream());
            BufferedReader inReader = new BufferedReader(new InputStreamReader(sk.getInputStream()));
            
            /* Send receiver to the server */            
            String receiver = jComboBox1.getSelectedItem().toString();
            jLabel3.setText("Sending receiver(" + receiver + ") to server");
            outputStream.write(receiver + "\n" );
            outputStream.flush();
            
            /* Send filename to server */
            jLabel3.setText("Sending filename to server");
            outputStream.write(fileDlg.getSelectedFile().getName() + "\n");
            outputStream.flush();

            /* Get reponse from server */
            jLabel3.setText("Handshaking...");
            String serverStatus = inReader.readLine();

            /* If server is ready, send the file */
            if (serverStatus.equals("READY")) {
                FileInputStream file = new FileInputStream(filename);
                
                /* Get the buffer length from the server */
                int len = Integer.parseInt(inReader.readLine());
                byte[] buffer = new byte[len];

                int bytesRead;

                total = 0;
                start = System.currentTimeMillis();

                while ((bytesRead = file.read(buffer)) > 0) {
                    total += bytesRead;
                    output.write(buffer, 0, bytesRead);
                    cost = System.currentTimeMillis() - start;
                    if ((cost > 0) && (System.currentTimeMillis() % 2 == 0)) {
                        speed = total / cost;
                        jLabel3.setText(speed + " KB/s");
                    }
                    jProgressBar1.setValue((int) ((total * 100) / filesize));
                }

                jLabel3.setText("Complete!");
                output.close();
                file.close();
                sk.close();
            }else {
                jLabel3.setText("Transfer declined");
                output.close();
                sk.close();
            }

            return 666;
        }