Solved

how to send big file using sockets?

Posted on 2003-11-05
5
343 Views
Last Modified: 2006-11-17
how can i send a big file from one pc to another using sockets in java? Also how to verify it without opening at other side whether it is transferred correctly or not?
0
Comment
Question by:panemade
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 45

Expert Comment

by:sunnycoder
ID: 9685723
Hi panemade,

>how can i send a big file from one pc to another using sockets
divide it into smaller parts (fragmentation) and send it part by part ... at the receiving end, join all the parts to get the complete file.

>Also how to verify it without opening at other side whether it is transferred correctly or not?
look into checksums .... anyway if you are using reliable protocol such as TCP, you would have received the file correctly ... it performs the required tests

Cheers!
Sunny:o)
0
 
LVL 1

Author Comment

by:panemade
ID: 10171515
can u give me some hint code or actual code to help to send a file using fragments?
 also how to join all fragments at receiveing end?
0
 
LVL 45

Accepted Solution

by:
sunnycoder earned 50 total points
ID: 10171555
skeleton ::

sender ::::
socket ()
connect()
fopen()
while ( fread ( ..n.. ) .. )
        send ( ..n.. )
send ( some special marker seqence indicating end of transfer )
fclose()
close()

receiver:::
socket()
bind()
listen()
accept()
fopen
whille ( not received marker sequence )
      recv()
     fwrite()
fclose()
close()
0
 
LVL 1

Author Comment

by:panemade
ID: 10171769
thats is great hint for me. so tell me one more thing to send a data on linux is it require a ip address of that computer? is it will not work only with name of that computer to send a data as dhcp assign it ip address that is not satic on my computer network?
0
 
LVL 45

Expert Comment

by:sunnycoder
ID: 10171797
use gethostbyname() to get IP address at run time
http://www.ecst.csuchico.edu/~beej/guide/net/html/syscalls.html#gethostname

you will find this tutorial very educative
http://www.ecst.csuchico.edu/~beej/guide/net/html/
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
In this article, I am going to show you how to simulate a multi-site Lab environment on a single Hyper-V host. I use this method successfully in my own lab to simulate three fully routed global AD Sites on a Windows 10 Hyper-V host.
Viewers will learn how to connect to a wireless network using the network security key. They will also learn how to access the IP address and DNS server for connections that must be done manually. After setting up a router, find the network security…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question