• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to check whether a file exits in a server or not ?

 
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
suppose i m connected with the server (a client server thing )
can i check whether a file exit in a server or not
but with file.exits() i guess it only works with current system
so how to do this , i know there must be something in java for the same ?
 
Saloon Keeper
Posts: 7585
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How are you connecting to the server? Which protocol?
 
naved momin
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Moores wrote:How are you connecting to the server? Which protocol?


suppose there is an application running on a remote desktop which has a server code which keep his port 6000 open for all his client to connect to the server, so i will make a code to connect on that port but, what next , how could i figure out whether this particular file exits on the server or not (its not a hacking thing , so dont misunderstand me)
is there any way ? huh
 
Tim Moores
Saloon Keeper
Posts: 7585
176
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, now we know that the remote machine is listening on port 6000. What we still don't know is what kind of server is listening on port 6000. What protocol does it understand? FTP? HTTP? WebDAV? Something else? None of the above? Just because the firewall allows incoming connections on a port does not mean that there is a process listening on that port.
 
naved momin
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Moores wrote:Ok, now we know that the remote machine is listening on port 6000. What we still don't know is what kind of server is listening on port 6000. What protocol does it understand? FTP? HTTP? WebDAV? Something else? None of the above? Just because the firewall allows incoming connections on a port does not mean that there is a process listening on that port.


i m doing this for the first time ..but lets see
suppose i have written a program to connect to the server and i will execute it in my machine so , the code will connect to the server because port 6000 is open ..ok
so can i write instruction in that code to check if that server has a file or not ...is this thing possible

2nd option is through any 3rd party ftp connection app that will connect me to the server and i can browse the files but i dont want this option

all i want to write code that performs that operation i need ....so to perform that i need to connect to the server i will do that in a sec but what later can i write code to perform file check from client to that server is this possible ?

 
Tim Moores
Saloon Keeper
Posts: 7585
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The client can't do anything to check for the file directly. The server process listening on port 6000 needs to do that; if it's written in Java it can use all the classes in the java.io package for file I/O.

It sounds a bit as if you're not quite clear on how client/server computing works, so again: there needs to be a process that's listening on port 6000, and that performs whatever operations you intend to be done. If there is no such process, then there's nothing the client can do about that.

It would probably be a good idea to work through the Java Tutorial on socket communication: http://download.oracle.com/javase/tutorial/networking/sockets/index.html It includes a fully-functional pair of client and server apps.
 
naved momin
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Moores wrote:The client can't do anything to check for the file directly. The server process listening on port 6000 needs to do that; if it's written in Java it can use all the classes in the java.io package for file I/O.

It sounds a bit as if you're not quite clear on how client/server computing works, so again: there needs to be a process that's listening on port 6000, and that performs whatever operations you intend to be done. If there is no such process, then there's nothing the client can do about that.

It would probably be a good idea to work through the Java Tutorial on socket communication: http://download.oracle.com/javase/tutorial/networking/sockets/index.html It includes a fully-functional pair of client and server apps.

i understand a bit of your answer ....what you are saying is that i need to send some instruction to the server process so that it can check whether the file it receive is available in server or not ?....(and yes server is written in java)
 
Tim Moores
Saloon Keeper
Posts: 7585
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Correct. You'll need to design some simple protocol that client and server can use to communicate; something like the "KnockKnockProtocol" in that example. Be sure to address authentication, so that not just any client can connect, but only authorized ones.
 
naved momin
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Moores wrote:Correct. You'll need to design some simple protocol that client and server can use to communicate; something like the "KnockKnockProtocol" in that example. Be sure to address authentication, so that not just any client can connect, but only authorized ones.


k fine i have finally got this functionality up
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic