Downloading file from user
Moderator: Moderators
Downloading file from user
Hi its me (again) i have few questions
1)How to use $Direction especialy number at end of this command
2)How to "decode' downloaded MyList file
3)Does <filename&path> in $Get and $SR are the same ?
It always shows File not awaliable
Thats all for now
Bye
1)How to use $Direction especialy number at end of this command
2)How to "decode' downloaded MyList file
3)Does <filename&path> in $Get and $SR are the same ?
It always shows File not awaliable
Thats all for now
Bye
Sorry for my ENG , but i hope u'll understand me.GreetZ
Re: Downloading file from user
the number is a random number.r4v3 wrote:1)How to use $Direction especialy number at end of this command
when both clients want to download from eachother, the one with the highest number wins. iirc
http://dc.selwerd.nl/hublist.xml.bz2
http://www.b.ali.btinternet.co.uk/DCPlusPlus/index.html (TheParanoidOne's DC++ Guide)
http://www.dslreports.com/faq/dc (BSOD2600's Direct Connect FAQ)
http://www.b.ali.btinternet.co.uk/DCPlusPlus/index.html (TheParanoidOne's DC++ Guide)
http://www.dslreports.com/faq/dc (BSOD2600's Direct Connect FAQ)
Re: Downloading file from user
1) Exactly as pointed out above.r4v3 wrote:Hi its me (again) i have few questions
1)How to use $Direction especialy number at end of this command
2)How to "decode' downloaded MyList file
3)Does <filename&path> in $Get and $SR are the same ?
It always shows File not awaliable
Thats all for now
Bye
2) The original Neo-Modus uses Huffman encoding. DC++ uses BZIP2 compression.
3) They are identical. They are case sensitive though. Other than this check for things like trailing backslashes etc...
Heh its not wiorking ,when i send:
$Search ....AAA
Server respond with $SR <ownname> <filenamewithpath><filesizeinbytes> <current openslots>/<allopenslots><hubname>
so i take <filenamewithpath> and send $Get <filenamewithpath> (after Key , lock etc...) and client respond with File not Avaliable
Its strange beacouse ther isn't drive letter in some responds.And how client knows withch file upload ?
For example
I have 2 files:
C:\Dir\file.txt
D:\Dir\file.txt
And clients sends to me : $Get Dir\file.txt , witch file shoul i upload ?.
DC protocal is strange...
$Search ....AAA
Server respond with $SR <ownname> <filenamewithpath><filesizeinbytes> <current openslots>/<allopenslots><hubname>
so i take <filenamewithpath> and send $Get <filenamewithpath> (after Key , lock etc...) and client respond with File not Avaliable
Its strange beacouse ther isn't drive letter in some responds.And how client knows withch file upload ?
For example
I have 2 files:
C:\Dir\file.txt
D:\Dir\file.txt
And clients sends to me : $Get Dir\file.txt , witch file shoul i upload ?.
DC protocal is strange...
Sorry for my ENG , but i hope u'll understand me.GreetZ
If you're sharing the complete drive, you should include the drive letter in the name - so if you share C:\Dir\file.txt and D:\Dir\file.txt, and the user requests Dir\file.txt, you should answer with 'File not shared'...
OTOH, if you just shared the 'Dir' folder from both drives, you'll have to add a suffix to one of them (DC++ adds a to the second, b to the third etc.; NMDC doesn't allow you to share two folders with identical names).
OTOH, if you just shared the 'Dir' folder from both drives, you'll have to add a suffix to one of them (DC++ adds a to the second, b to the third etc.; NMDC doesn't allow you to share two folders with identical names).
The drive letter is not used by DC++.r4v3 wrote:[snip]
Its strange because there isn't drive letter in some responds. And how [does the] client knows which file [to] upload?
For example
I have 2 files:
C:\Dir\file.txt
D:\Dir\file.txt
And clients send to me : $Get Dir\file.txt , which file should i upload ?.
DC protocol is strange...
DC++ would share those two directories as
Dir\file.txt (-> C:\Dir\file.txt)
Dira\file.txt (-> D:\Dir\file.txt)
In this way the problem you describe does not appear.
Sarf
---
I like people, but I like myself better.
-
- Posts: 506
- Joined: 2003-01-03 07:33
thanx , now i can download files but i have problem with saving it to disk.
Jm writtening my client with Java and i have no problems with *.txt files - evrything is ok , but when I download *.jpg , *.mp3 and other binary files i cant open them.
This is how I do this:
Connection to user:
try{
ss = new ServerSocket(port);
s = ss.accept();
}catch(UnknownHostException uhe)
{
return;
}catch(IOException ioe)
{
return;
}
try{
br = new BufferedReader(new InputStreamReader(s.getInputStream()));
os = s.getOutputStream();
}catch(IOException ioe)
{
return;
}
Afther $Send command :
int znak= br.read();
fos.write(znak);
where fos is FileoutputStream; ex. new FileOutputStream("File.dat" , true);
I thing there is a problem with outputstream maybe i shoud use some other stream ? (like DataOutputStream)
Afther download :
fos.close();
Thats all , if samoe could help me (once again)
Thanx
Jm writtening my client with Java and i have no problems with *.txt files - evrything is ok , but when I download *.jpg , *.mp3 and other binary files i cant open them.
This is how I do this:
Connection to user:
try{
ss = new ServerSocket(port);
s = ss.accept();
}catch(UnknownHostException uhe)
{
return;
}catch(IOException ioe)
{
return;
}
try{
br = new BufferedReader(new InputStreamReader(s.getInputStream()));
os = s.getOutputStream();
}catch(IOException ioe)
{
return;
}
Afther $Send command :
int znak= br.read();
fos.write(znak);
where fos is FileoutputStream; ex. new FileOutputStream("File.dat" , true);
I thing there is a problem with outputstream maybe i shoud use some other stream ? (like DataOutputStream)
Afther download :
fos.close();
Thats all , if samoe could help me (once again)
Thanx
Sorry for my ENG , but i hope u'll understand me.GreetZ
Just one thing, enclose your code within code brackets to preserve your formatting.r4v3 wrote:thanx , now i can download files but i have problem with saving it to disk.
You should not use the BufferedReader. It is inappropriate, and might cause errors.
I read somewhere about a fixed limit after which the clients have to acknowledge each other - but I am probably wrong.
Here's my code that might fix your problem (as well as a few others along the way - as usual I do not know when to stop ):
Code: Select all
protected static int sReadBufferSize = 16384;
public synchronized static int getReadBufferSize()
{
return sReadBufferSize;
}
public synchronized static void setReadBufferSize(int bufferSize)
{
sReadBufferSize = bufferSize;
}
public static void handleStreams(InputStream is, OutputStream os)
throws IOException
{
// use assertions here instead
if(is == null) throw new NullPointerException("inputstream may not be null");
if(os == null) throw new NullPointerException("outputstream may not be null");
// the only reason not to do a os.write(is.read()) is that it is *very* slow to do that many calls
byte[] buffer = new byte[getReadBufferSize()];
int bytesRead = 0;
try
{
while(true)
{
bytesRead = is.read(buffer);
os.write(buffer, 0, bytesRead);
}
}
catch(IOException ex)
{
flush(os);
throw ex;
}
}
void flush(OutputStream os)
{
try
{
os.flush();
}
catch(IOException ex) { }
}
void close(OutputStream os)
{
try
{
os.close();
}
catch(IOException ex) { }
}
void receiveDataToFile(InputStream is, FileOutputStream fos)
{
BufferedInputStream bis = new BufferedInputStream(is);
BufferedOutputStream bos = new BufferedOutputStream(fos);
try
{
handleStreams(is, os);
}
catch(IOException ex)
{
}
flush(bos);
}
void handleConnection(Socket s)
throws ConnectionException
{
/* After $Send command : */
// fos is a FileOutputStream
receiveDataToFile(s.getInputStream(), fos);
close(fos);
}
protected boolean mShouldBlock;
protected synchronized boolean getShouldBlock()
{
return mShouldBlock;
}
protected synchronized void setShouldBlock(boolean shouldBlock)
{
mShouldBlock = shouldBlock;
}
void setUpConnection()
throws ConnectionException
{
try
{
ss = new ServerSocket(port);
// this here code makes sure we won't wait forever for a connection
ss.setSoTimeout(1000);
do
{
try
{
s = ss.accept();
// put handleconnection in a thread to handle multiple clients
handleConnection(s);
}
catch(SocketTimeoutException ex)
{
}
} while(getShouldBlock())
}
catch(BindException ex)
{
throw new ConnectionException("could not bind to port " + port + " - it was already taken");
}
catch(UnknownHostException ex)
{
throw new ConnectionException("could not get IP of host");
}
catch(IOException ex)
{
throw new ConnectionException("unspecified error", ex);
}
}
Sarf
---
A liberal is a conservative who has been arrested.
One more question (i coudnt find answer in few protocol documentations)
How to resume disconnected downloads ?
$Get <filename>$number
what number is this i hered that is a number of resumes.
Maybe it is a number of byte I want to start download ?
How to resume disconnected downloads ?
$Get <filename>$number
what number is this i hered that is a number of resumes.
Maybe it is a number of byte I want to start download ?
Sorry for my ENG , but i hope u'll understand me.GreetZ
yes, number is the byte offset (starting at 1, not 0)r4v3 wrote:$Get <filename>$number
http://dc.selwerd.nl/hublist.xml.bz2
http://www.b.ali.btinternet.co.uk/DCPlusPlus/index.html (TheParanoidOne's DC++ Guide)
http://www.dslreports.com/faq/dc (BSOD2600's Direct Connect FAQ)
http://www.b.ali.btinternet.co.uk/DCPlusPlus/index.html (TheParanoidOne's DC++ Guide)
http://www.dslreports.com/faq/dc (BSOD2600's Direct Connect FAQ)