CN5 1 1
CN5 1 1
STD : T.E.
ROLL NO. :
PRACTICAL NO. 05
Socket programming.
import java.net.*;
import java.io.*;
PrintWriter pw = null;
try {
while (true) {
dsoc.receive(dp);
System.out.println(receivedData);
pw.println(receivedData);
} catch (IOException e) {
e.printStackTrace();
} finally {
if (pw != null) {
pw.close();
dsoc.close();
Output :
import java.net.*;
import java.io.*;
try {
int bytesRead;
dsoc.send(packet);
} catch (IOException e) {
e.printStackTrace();
} finally {
// Close resources
if (fis != null) {
try {
fis.close();
} catch (IOException e) {
e.printStackTrace();
dsoc.close();
} Output :