Results 1 to 1 of 1
- 05-14-2010, 06:41 PM #1
Member
- Join Date
- May 2010
- Posts
- 1
- Rep Power
- 0
Problems with sending zip file using Socket
hello people,
i need from your knowledge. I have a Client program and a Server Program.
I need to send a zip File using socket but i can not. My programs send a File.txt, but i don't know what change them, to make them work.
Please, Help me!!
this is may code from my client who send the File.txt
this is my reciving code from my server who save the File.txttry {
File f1 = new File ("mine.zip");
FileInputStream fins = new FileInputStream(f1);
byte inputByte = (byte)fins.read();
//byte inputByte = (byte)fins.read();
DataOutputStream out = new DataOutputStream(skCliente.getOutputStream());
System.out.println("client: start sending file ...\n ");
while (inputByte != -1)
{
out.write(inputByte); // write to socket
out.flush();
inputByte=(byte)fins.read();
}
out.close();
System.out.println("File sent to server!");
}catch(Exception e){}
try
{
File f1 = new File ("l_mine.zip");
FileOutputStream fout = new FileOutputStream(f1);
DataInputStream in = new DataInputStream(skCliente.getInputStream());
int inByte = (int)in.read();
System.out.println("\nServer receiving file\n");
while(inByte != -1)
{
fout.write(inByte); //write it to socket's stream
fout.flush();
inByte = (byte)in.read();
System.out.println("server: receiving file bit by bit\n");
}
fout.close();
} catch (IOException e){}
Please, help me, i'll apreciated... :(
Similar Threads
-
sending file from client to server - socket closed error
By forex in forum NetworkingReplies: 3Last Post: 04-05-2010, 02:19 AM -
sending object through network/socket
By skandalouz in forum NetworkingReplies: 1Last Post: 12-24-2009, 07:34 AM -
Sending a file through socket
By sureshkumarcs88 in forum NetworkingReplies: 2Last Post: 03-14-2009, 07:32 AM -
Sending a .Doc file from client to a server through socket
By amita_k29 in forum NetworkingReplies: 1Last Post: 02-10-2009, 09:16 AM -
Problems sending file throught TCP sockets
By Nite in forum Advanced JavaReplies: 2Last Post: 08-04-2007, 09:01 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks