This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Download file from socket

Old posts that have not been replied to for several years.
Locked
c
cerberus_gr
Halfop
Posts: 97
Joined: Fri Feb 07, 2003 8:57 am
Location: 127.0.0.1

Download file from socket

Post by cerberus_gr »

I don't know if the topic is the best, but this is that I want to do:

I have connected to a server througth connect and listen commands.
Someone from this server sent me a dcc file. How could I take this file.

1) What should I do when I see the ctcp dcc send command? Just open a listen port in my eggdrop and send ctcp dcc send accept command?

2) When the transfer begins, how could be sure that the file saves in binary format (is this right?)?
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

dccsend command should take care of this unless ur willing to write one of ur own .. load the transfer module

hmm and to answer ur question i think its like this open the file fconfigure the channel to bin then read it and send it to the socket or idx if u prefer that .. maybe could use
filesend <idx> <filename> [ircnick]
command if u wana do it like this .. then i gues u don't have to open the file and read it u just could do filesend
XplaiN but think of me as stupid
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Re: Download file from socket

Post by user »

cerberus_gr wrote:I don't know if the topic is the best, but this is that I want to do:

I have connected to a server througth connect and listen commands.
Someone from this server sent me a dcc file. How could I take this file.

1) What should I do when I see the ctcp dcc send command? Just open a listen port in my eggdrop and send ctcp dcc send accept command?

2) When the transfer begins, how could be sure that the file saves in binary format (is this right?)?
Eggdrop's socket commands can't be used to transmit binary data. Use 'socket' or the commands provided by the transfer module.
Opening a listening socket won't do you much good :P
When you get a ctcp "dcc send" you'll have to connect to the ip and port provided in the ctcp. The transfer begins as soon as you connect, so just save whatever you recieve after connecting. (using 'fcopy' can make this part alot easier)
Have you ever read "The Manual"?
c
cerberus_gr
Halfop
Posts: 97
Joined: Fri Feb 07, 2003 8:57 am
Location: 127.0.0.1

Post by cerberus_gr »

Is this correct?

Code: Select all

proc fsdb:receive:file { id file host port } {
    global fsdb

    set outfile [open "$fsdb(tempdir)$file" w]
    set infile [connect $host $port]
    fcopy $infile $outfile -command [list fsdb:end:file $id $infile $outfile]
    vwait total($id)
}

proc fsdb:end:file { id infile outfile bytes {error {}} } {
    global total
    set total($id) $bytes
    close $infile; close $outfile
    if {[string length $error] != 0} { lkdsl }
}
How could I take an standard ip from a longip format?
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

Code: Select all

proc ip2longip {ipaddr} {
  foreach ipbyte [split $ipaddr \x2E] { 
    append hexaddr [format {%02x} $ipbyte] 
  } 
  return [format {%u} "0x$hexaddr"] 
}
XplaiN but think of me as stupid
c
cerberus_gr
Halfop
Posts: 97
Joined: Fri Feb 07, 2003 8:57 am
Location: 127.0.0.1

Post by cerberus_gr »

Ofloo thanks.

Is there any procedure for longip2ip?

Is my code with fcopy correct? ;)
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

'fcopy' deals with file channels. You'll have to use 'socket', not 'connect' if you want a file channel. And there's no need to convert the ip because 'socket' understands the decimal ip as it is in the ctcp just fine.

Here's a couple of procs to convert ips anyway :P

Code: Select all

proc dec2dot ip {join [scan [format %.8X $ip] %2x%2x%2x%2x] .}
proc dot2dec ip {format %u 0x[eval format %.2X%.2X%.2X%.2X [split $ip .]]}
Have you ever read "The Manual"?
c
cerberus_gr
Halfop
Posts: 97
Joined: Fri Feb 07, 2003 8:57 am
Location: 127.0.0.1

Post by cerberus_gr »

user you are the best. Thx!!!!
Locked