Writing Text to a Socket

try {
    BufferedWriter wr = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
    wr.write("aString");
    wr.flush();
} catch (IOException e) {
}

Comments

13 Jan 2010 - 9:14pm by Agustín (not verified)

How can I send an excel file using a socket ???

23 Jan 2010 - 9:40am by Korion (not verified)

How to transfer File and image as jpg using Tcp socket if you please give some info will be excellent
thank you

4 Mar 2010 - 12:41am by Zohaib (not verified)

I am trying to communicate between a java server and a C client,
The problem is that my server is writing to the socket using DataOutputStream and i am not allowed to change that. So the C client is not able to properly read because it uses buffer.
I am using read(socket,buffer,strlen(buffer)) in C to read.

4 May 2010 - 4:52pm by Anonymous (not verified)

for what flush() is used? i can't catch.

24 May 2010 - 8:06am by Anonymous (not verified)

flush() lets the receiver know data is being sent i believe

3 Mar 2011 - 9:56am by erichax (not verified)

flush() is used because in this example a buffered writer is used. this means write() writes to a buffer (in memory), and might not be sent through socket right away. when you flush(), the buffer is written to the socket no matter how small it may be and the receiver gets it right away.

15 Jan 2012 - 8:35am by Anonymous (not verified)

also, the memory declared by the writer is reset

17 Jan 2012 - 11:32pm by North Face Outlet (not verified)

Current elements North Face Outlet of tent pole include things like fiberglass, aluminum and carbon compounds fiber. Tubular Mens North Face glass soluble fiber consideration bar is by much most in all likelihood the usually implemented consideration which may in all likelihood be collapsed.Aluminum North Face Women tent pole can be obviously common within our North confront by way of the world marvelous internet Outlet which developed with exclusively the precise same blend of glass fiber.

17 Jan 2012 - 11:32pm by North Face Store (not verified)

Borealis retailer North Face Store back once more right, are hassle-free copouts from executing a little bit Moncler Outlet work to obtain out what is wrong. not simply that, but all it achieves is commonly to Moncler reduce your time-span and could also change what must be an uncomplicated work directly into a eco-friendly directly into a headache seeking to obtain in too much of a amount of traps.

Post a comment

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image. Ignore spaces and be careful about upper and lower case.