mIRC Home    About    Download    Register    News    Help

Print Thread
Receiving DCC files through sockets #38539 27/07/03 07:39 AM
Joined: Jan 2003
Posts: 30
R
Rooster74 Offline OP
Ameglian cow
OP Offline
Ameglian cow
R
Joined: Jan 2003
Posts: 30
I figured out how to accept dcc sends through sockets and how to send files, but I am having problems recieving them. The connection accepts, but I am missing something in the sockread portion because the file stalls mid way through every time.
Code:
on *:SOCKREAD:dcc.*:{
  if ($sockerr) { return }
  sockread 4096 &dcc
  while ($sockbr) {
    bwrite %filename -1 -1 &dcc
    sockread 4096 &dcc
  }
}

Does anyone have any ideas on what I'm doing wrong?

Re: Receiving DCC files through sockets #38540 27/07/03 10:53 AM
Joined: May 2003
Posts: 730
S
ScatMan Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: May 2003
Posts: 730
on *:SOCKREAD:dcc.*:{
if ($sockerr) { return }
while ($sock($sockname).rq) {
sockread 4096 &dcc
bwrite %filename -1 -1 &dcc
}
}

Re: Receiving DCC files through sockets #38541 27/07/03 01:05 PM
Joined: Dec 2002
Posts: 117
R
Rich Offline
Vogon poet
Offline
Vogon poet
R
Joined: Dec 2002
Posts: 117
The reason the transfer stops is because you're not following the DCC protocol: this requires the receiver to acknowledge all received data by sending back the total number of received bytes.
(see http://www.user-com.undernet.org/documents/dccinfo.html)

Code that should work: (but has not been tested at all)
Code:
on *:SOCKREAD:dcc.*:{
  if ($sockerr) { echo sockerror! | return }
  sockread 4096 &dcc
  while ($sockbr) {
    bwrite %filename -1 -1 &dcc
    sockread 4096 &dcc
  }

  ;get number of received bytes
  var %rcvd = $sock($sockname).rcvd
  ;$longip converts this from decimal to base 256 
  ;  (you could use some complicated $calc with a lot of % 256 but this takes less code)
  ;then replace the dots with spaces, put it in the binvar and send it
  bset &rcvd 1 $replace($longip(%rcvd),.,$chr(32))
  sockwrite $sockname &rcvd
}


$input(Me like stars, You too?)
Re: Receiving DCC files through sockets #38542 27/07/03 03:53 PM
Joined: Jan 2003
Posts: 30
R
Rooster74 Offline OP
Ameglian cow
OP Offline
Ameglian cow
R
Joined: Jan 2003
Posts: 30
Thank you, that worked perfectly. I had read in another thread elsewhere that I needed to send an acknowledgement back, but none of the dcc protocal information I could find specified exactly what I needed to send back.

Re: Receiving DCC files through sockets #38543 29/07/03 04:10 AM
Joined: Jan 2003
Posts: 30
R
Rooster74 Offline OP
Ameglian cow
OP Offline
Ameglian cow
R
Joined: Jan 2003
Posts: 30
One other question I thought of, how can I tell the download speed?

Re: Receiving DCC files through sockets #38544 06/11/03 09:04 PM
Joined: May 2003
Posts: 19
M
Massacre Offline
Pikka bird
Offline
Pikka bird
M
Joined: May 2003
Posts: 19
I am building an app in java that received DCCs but I'm having alot of trouble making mirc understand the msg I'm sending back stating the bytes received. I'm doing the following which I think matches the above: taking the number of bytes written, eg. 4096 and converting it to "shortip" format via a (working) method that returns an IP type number. I then write each section (tokenized by '.') as an Integer to the stream and send. mIRC doesn't like it. I've spent hours trying different methods. Here is an example of what would be written for 4096:

0
0
16
0

Is that right? and if not does anyone know what it should be and how to get there?

Re: Receiving DCC files through sockets #38545 07/11/03 01:58 PM
Joined: Dec 2002
Posts: 117
R
Rich Offline
Vogon poet
Offline
Vogon poet
R
Joined: Dec 2002
Posts: 117
You should just send 32 bits specifying how much you received:
If you received 4096 bytes you would send $chr(0) $+ $chr(0) $+ $chr(16) $+ $chr(0)


$input(Me like stars, You too?)