Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

transfer files but there is no content in the file only the file name is transferred  RSS feed

 
shen zhang
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all

Anyone can help me with my code? i got error at server side, and i tried to change port numbers but the errors seems still the same.

thank you guys in advance, really want someone good at java can help me with this problems!!!

at client side


at server side



These are the errors

Exception in thread "main" java.net.BindException: Address already in use: JVM_Bind
at java.net.DualStackPlainSocketImpl.bind0(Native Method)
at java.net.DualStackPlainSocketImpl.socketBind(Unknown Source)
at java.net.AbstractPlainSocketImpl.bind(Unknown Source)
at java.net.PlainSocketImpl.bind(Unknown Source)
at java.net.ServerSocket.bind(Unknown Source)
at java.net.ServerSocket.<init>(Unknown Source)
at java.net.ServerSocket.<init>(Unknown Source)
at ServerRun.main(ServerRun.java:33)
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might want to use something like netstat -a to figure out the ports in use on your machines
 
shen zhang
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Maneesh
thank you for the reply
I did, but error is still the same. and also running the program, the transfer the file is also wrong. is there other way to solve my problems? thanks
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which command did you run on your server machine?
What was the output?
Please copy paste the console output so we can view it

Which port are you trying to use in your code?
 
shen zhang
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi

this is the console on the client side
1.png
[Thumbnail for 1.png]
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please do not post images. One cannot search for content inside an image.
I meant the console output when you ran the command 'netstat -a' in your terminal/command prompt
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The error your image shows is different than the one you had mentioned earlier.
To help us best help you please tell us exactly what is going wrong
 
shen zhang
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi it will show using port numbers , start from 5027...
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
shen zhang wrote:hi it will show using port numbers , start from 5027...

Since my crystal ball is broken and I do not have access to your machine, I do not think I will be able to help you unless you can provide the information I requested.
 
shen zhang
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the problems when i run the program both side client and server in the same machine, my output folder's file do not have any context inside, for example, if i want to transfer a file1.txt 2kbyte into output folder, i can see the file in the output folder, but when i open the file, there is nothing inside. meanwhile, when i run the program, the console keep saying error at my port is wrong, but i check command, the port number is fine, no problem.

Thank you for seeking my problem
 
Joe Ess
Bartender
Posts: 9429
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Since this line includes the word "student", I take it this is an educational project? Perhaps you should ask your instructor to clarify the assignment and help you with any problems.
If you want our help, Maneesh is going down the right path. Your server will not run because the port number you are trying to use is occupied, hence his request for "netstat -a". Your client won't run unless your server is running. As for your question directly above, perhaps this FAQ article will help.
 
shen zhang
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Joe Ess wrote:

Since this line includes the word "student", I take it this is an educational project? Perhaps you should ask your instructor to clarify the assignment and help you with any problems.
If you want our help, Maneesh is going down the right path. Your server will not run because the port number you are trying to use is occupied, hence his request for "netstat -a". Your client won't run unless your server is running. As for your question directly above, perhaps this FAQ article will help.

HI thank you, I managed to run the program, however, it only transfer one file, the rest will not show up, could you advise me why is that so from my program i posted above?
 
Partheban Udayakumar
Ranch Hand
Posts: 499
AngularJS Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
shen zhang

Kindly check your client side coding.



The dos.close(); in the above for loop closes the socket after one file transfer so you won't be able to transfer other files.
 
shen zhang
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Partheban Udayakumar wrote:shen zhang

Kindly check your client side coding.



The dos.close(); in the above for loop closes the socket after one file transfer so you won't be able to transfer other files.


Hi Partherban

Thank you so much! Thank you so much for taking your time to help me with my code, thanks!

 
shen zhang
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,

anyone knows about Timing, for instant, if i want to transfer files every 30 seconds from one folder to another folder, that means every 30 seconds I want to check see whether I have new files to be transferred to another folder, is there a such method? what is called? Thank you!
 
Partheban Udayakumar
Ranch Hand
Posts: 499
AngularJS Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
shen zhang

No problem and as for timer you can use Timer and TimerTask classes or cron jobs

 
shen zhang
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all

at server side, line 88, while loop condition, has an error, but it seems correct, why after run for a while, they say error on line 88, and also only the first file cannot be transferred!!! please help! thank you
 
shen zhang
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all

My question is, from this code is able to transfer files but the context are all wrong. I cannot read from here. Please advise me where is the problem? Thank you!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!