Java Socket Write writeUTF(final Socket socket, final String out)

Here you can find the source of writeUTF(final Socket socket, final String out)

Description

write UTF

License

Open Source License

Declaration

static int writeUTF(final Socket socket, final String out) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.DataOutputStream;

import java.io.IOException;
import java.net.Socket;

public class Main {
    static int writeUTF(final Socket socket, final String out) {
        //Logger.logD("enter trace");

        if (out != null) {
            //Logger.logD("out != null");

            if (socket != null) {
                //Logger.logD("socket != null");

                try {
                    //Logger.logD("getting dos");

                    DataOutputStream dos = new DataOutputStream(socket.getOutputStream());

                    //Logger.logD("got dos");

                    //Logger.logD("performing write");

                    dos.writeUTF(out);/*w  w  w .  j a v a2  s .  c o  m*/

                    //Logger.logD("performing flush");

                    dos.flush();

                    //Logger.logD("exit trace");

                    return 0;
                } catch (IOException e) {
                    e.printStackTrace();

                    //Logger.logD("exit trace");

                    return -3;
                }
            }
            //Logger.logD("exit trace");

            return -2;
        }
        //Logger.logD("exit trace");

        return -1;
    }
}

Related

  1. openWriter(Socket socket)
  2. writeData(Socket id, byte[] data, int len)
  3. writeDatasIntoSocket(Socket socket, String datas)
  4. writeFromServer(Socket sck, String row)
  5. writeOutputStream(Socket socket, StringBuffer sb)