Create A Socket For HTTP For Web Page Upload and Download
Create A Socket For HTTP For Web Page Upload and Download
Create A Socket For HTTP For Web Page Upload and Download
Aim:
To write a java program for socket for HTTP for web page upload and download .
Algorithm
5.If your frames reach the server it will send ACK signal to client otherwise it will send NACK signal to
client.
Program :
Client
/* Client Side Program for File Upload and Download */
import javax.swing.*;
import java.net.*;
import java.awt.image.*;
import javax.imageio.*;
import java.io.*;
try {
baos.flush();
dos.writeInt(bytes.length);
dos.write(bytes, 0, bytes.length);
dos.close();
out.close();
soc.close();
soc.close();
Server
import java.net.*;
import java.io.*;
import java.awt.image.*;
import javax.imageio.*;
import javax.swing.*;
class Server {
ServerSocket server=null;
Socket socket;
server=new ServerSocket(4000);
InputStream in = socket.getInputStream();
dis.readFully(data);
dis.close();
in.close();
l.setIcon(icon);
f.add(l);
f.pack();
f.setVisible(true);
Output
When you run the client code, following output screen would appear on client side.