File Transfer over Sockets


 
Thread Tools Search this Thread
Top Forums Programming File Transfer over Sockets
Prev   Next
# 1  
Old 01-05-2009
File Transfer over Sockets

Hello there !!!!!!!!! I got some problems trying to transfer a file through sockets.

The Server must be in Java and the Client in C++

I came up with this code for the server :

BufferedInputStream input;
BufferedOutputStream output;
public void send_data() throws IOException
{
File transfer = new File("tux.png");
InputStream in = new FileInputStream(transfer);


byte[] buff = new byte[sock.getSendBufferSize()];
int bytesRead = 0;

System.out.println(transfer.length()+ " bytes");

while((bytesRead = in.read(buff))>0)
{
output.write(buff,0,bytesRead);
}
in.close();
}
public void recv_data() throws IOException
{
InputStream input = sock.getInputStream();
FileOutputStream wr = new FileOutputStream(new File("Test"));
byte[] outBuffer = new byte[sock.getReceiveBufferSize()];
int bytesReceived = 0;

while((bytesReceived = input.read(outBuffer))>0)
{
wr.write(outBuffer,0,bytesReceived);
}
wr.close();


}



But i can not do the client side in C++. Can anybody give an example??
If the code a give you is very confusing , it would be OK to give a very simple example of how to send/recv a file from/to client(C++)/server/(Java)


Thank you in advance.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

File transfer

When using FTP to transfer a file from IBM iSeries family of servers client to a non IBM Iseries family server, files might have characters appear in the wrong format Eg | in Iseries and while transferring fro Iseries system to Linux , but instead of | it is showing as ?. Please advise (3 Replies)
Discussion started by: sudhainit
3 Replies

2. Shell Programming and Scripting

File transfer script

Hi, I need a shell script to transfer a file from one server(unix box) to another server(windows box). I have the details of the source and destination Ip's. source path : /home/UNIX/server filename:abc.txt Destination folder: D:/UNIX/test I am using AIX server. Type of shell :... (1 Reply)
Discussion started by: NareshN
1 Replies

3. Shell Programming and Scripting

Avoiding file overwrite during file transfer using scp

Hi, I have written a small script to transfer a file from one unix server to other using scp command which is working fine. As I know with scp, if any file with the same name is already present on destination server, it would get overwritten without any notification to user. Could anyone help me... (14 Replies)
Discussion started by: dsa
14 Replies

4. Programming

File transfer in C

HI Can anyone provide me with codes for file transfer server to client or vice versa? Also please explain how to compile those programs in ubuntu terminal as i am totally new to socket programming. Thanks (0 Replies)
Discussion started by: mayhemtrigger
0 Replies

5. Programming

Sending large file through sockets

Hello, I am trying to send a file (1 MB) through sockets and for some reason I am getting segmentation fault message and receiving in the server an incomplete file. The current file is about 3 pages long and need to send it from the client to the server. I've tried malloc with free(), I am now... (8 Replies)
Discussion started by: sfcddm1
8 Replies

6. Programming

Problem in file transfer using sockets

Hai Friends I am writing a c program to transfer files from one system to another using TCP/IP socket programming.. My Recieve Program #include <stdio.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> extern int errno; extern char *sys_erlist; void... (2 Replies)
Discussion started by: collins
2 Replies

7. Shell Programming and Scripting

File transfer

Hi All, it might not be an sound question, i have two server like A and B.. i want to transfer file from B to A ..here i have some questions.. 1) do we need to create private and public key to connect..and transferring files...from B to A..? 2) i tried with scp options like... (2 Replies)
Discussion started by: Shahul
2 Replies

8. UNIX for Dummies Questions & Answers

Transfer the file

Dear all, Can anybody let me know how to automate a file transfer process to a remote m/c thru SFTP , automate means it will not prmpt for password. how i am going to achive this....and what all methods are available or tools are available ???? (2 Replies)
Discussion started by: manas_ranjan
2 Replies

9. Shell Programming and Scripting

file transfer

hi all how do i copy a file from one server to another thanks bkan77 (4 Replies)
Discussion started by: bkan77
4 Replies

10. Programming

Sockets and File descriptors

I am in a Systems programming class this semester, and our current project is to write a program utilizing sockets and fork. For the project, I decided to make my own instant messaging program. I have the code completed, but I have a problem that keeps old clients from communicating with new... (3 Replies)
Discussion started by: gstlouis
3 Replies
Login or Register to Ask a Question
apertium-transfer(1)													      apertium-transfer(1)

NAME
apertium-transfer - This application is part of ( apertium ) This tool is part of the apertium open-source machine translation toolbox: http://www.apertium.org. SYNOPSIS
apertium-transfer trules preproc biltrans [input [output]] apertium-transfer -n trules preproc [input [output]] DESCRIPTION
apertium-transfer is the program that performs the transfer from input language into output language. Normally this program will not be used independently, but in combination with other programs: see apertium-translator (1). FILES
These are the five files that can be used with this command: trules Transfer rules file preproc Result of preprocess trules file biltrans Bilingual letter transducer file infile Input file (stdin by default). outfile Output file (stdout by default). -n Do not use a bilingual dictionary to process the input. SEE ALSO
apertium-translator(1), apertium (1). BUGS
Lots of...lurking in the dark and waiting for you! AUTHOR
Copyright (c) 2005, 2006 Universitat d'Alacant / Universidad de Alicante. This is free software. You may redistribute copies of it under the terms of the GNU General Public License <http://www.gnu.org/licenses/gpl.html>. 2006-03-08 apertium-transfer(1)