Accueil > > > CLIENT ET SERVEUR PERSO SOCKET (NON TERMINÉS)
CLIENT ET SERVEUR PERSO SOCKET (NON TERMINÉS)
Information sur la source
Description
Donc voila j'avais un projet : faire un client et un serveur sans le dcc, tout perso en socket. je ne metrise pas totalement les socket. j'ai essayer de le faire c'est deja pas mal! jusqu'au transfert de fichier qui ma serieusement butter donc j'ai abandonner ~:[ Le code => serveur : on choisit le port que l'on veut ouvrir, on ne peut pas ouvrir un port deja ouvert! (logik) c'est prévu d'ailleur.. ensuite peut soit mettre anonyme qui revient a une authentification comme si vous mettez un login et pass "anonymous" et on peut mettre qu'un pass bref.. on le run "hop" :D le client : donc dans le client pour se connecter au serveur on met l'auth qu'il faut.. une fois connecter il recherche les disk present sur le serveur, et les affiche bon apres c'est pas compliker a utiliser. Les problemes : je me suis arreter au transfert de fichier, j'ai reussi a down des fichiers en fait je pens pas que ce soit compliquer a quelqu'un qui connait bien les socket de "finir" "ameliorer" (oh oui) ,.. ça serait bien qu'une personne s'y penche (ça peut etre interessant) et il n'y a pas que du socket dedans :)
Source
- ;----Par-SkotMarud----
-
- ;-------------------------------------------
- ;----Server-sok----
-
- dialog server {
- title "server"
- size -1 -1 70 72
- option dbu
- text "Creation d'un serveur sok", 1, 4 2 67 8
- edit "", 2, 24 12 40 10
- text "Port :", 3, 8 13 15 8
- box "", 4, 2 8 66 62
- text "Pass :", 5, 8 33 15 8, disable
- text "User :", 6, 8 23 15 8, disable
- edit "", 7, 24 22 40 10, disable
- edit "", 8, 24 32 40 10, disable pass
- radio "User et Pass", 9, 24 44 40 8
- radio "Pass", 10, 24 52 22 8
- radio "Anonyme", 11, 24 60 34 8
- button "Ok", 12, 4 44 19 12, default
- button "No", 13, 4 56 19 12, cancel
- button "off", 14, 57 2 11 8
- }
- on 1:dialog:server:*:*:{
- if ($devent = init) {
- if (!$sock(server)) { did -b server 14 }
- if $sock(server) { did -ma server 2 $sock(server).port | did -e server 14 | did -b server 9,10,11,12,13 }
- did -c server 11
- }
- if ($devent = sclick) {
- if ($did = 9) { did -e server 5,6,7,8 }
- if ($did = 10) { did -e server 5,8 | did -b server 6,7 }
- if ($did = 11) { did -b server 5,6,7,8 }
- if ($did = 12) {
- if ($portfree($did(server,2)) = $false) { $input(Port déja utilisé $+ $str($chr(32),15) ,io,info) | did -r server 2 }
- if ($did(server,2) > $calc(2^16)) { $input(Port invalide $+ $str($chr(32),15) ,wo,info) | did -r server 2 }
- if ($portfree($did(server,2)) = $true) && ($did(server,2) < $calc(2^16)) && ($did(9).state = 1) { set %port.server $did(server,2) | set %user $did(server,7) $+ $chr(46) $+ $did(server,8) | soko | dialog -x server }
- if ($portfree($did(server,2)) = $true) && ($did(server,2) < $calc(2^16)) && ($did(10).state = 1) { set %port.server $did(server,2) | set %user $did(server,8) | soko | dialog -x server }
- if ($portfree($did(server,2)) = $true) && ($did(server,2) < $calc(2^16)) && ($did(11).state = 1) { set %port.server $did(server,2) | set %user anonymous $+ $chr(46) $+ anonymous | soko | dialog -x server }
- }
- if ($did = 14) { sockclose server | if $sock(server1) { sockclose server1 } | did -b server 14 | did -nr server 2 | did -e server 9,10,11,12,13 }
- }
- }
- ;--------------essai du serv-------------
- alias help {
- sockwrite -n server1 $str($chr(45),29) $crlf $+ HELP $chr(124) $+ Menu des commandes. $crlf $+ BYE $chr(124) $+ Deconnection. $crlf $+ DISK $chr(124) $+ Retourne les informations au sujet du disque dur specifie. $crlf $+ DIR $chr(124) $+ Affiche une liste de fichiers et de sous-repertoires dans un repertoire. $crlf $+ SDISK $chr(124) $+ Affiche disk/partition(s). $crlf $+ FILE $chr(124) $+ Affiche la taille du fichier. $crlf $+ $str($chr(45),29)
- }
- alias soko {
- socklisten server %port.server
- }
- on 1:socklisten:server:{
- set %regist 0
- sockaccept server1 %port.server | .timer 1 10 sockclose server1
- sockwrite -n server1 3-identification User and Pass $crlf
- }
- on 1:sockread:server1:{
- sockread %a
- if (%a = %user) && ($gettok(%regist,2,46) = 1) { sockwrite -n server1 2-user deja enregistre $crlf }
- if (%a = %user) && (%regist = 0) { sockwrite -n server1 1-login ok $crlf | set %regist $addtok(%regist,1,46) | .timer1 off }
- if (%a = bye) && ($gettok(%regist,2,46) = 1) { sockclose server1 }
- if (%a = help) && ($gettok(%regist,2,46) = 1) { help }
- if ($gettok(%a,1,46) = disk) && ($gettok(%regist,2,46) = 1) { sockwrite -n server1 $str($chr(45),29) | sockwrite -n server1 5-disk Path $disk($gettok(%a,2,46)).path $chr(124) Type $disk($gettok(%a,2,46)).type $chr(124) Name $disk($gettok(%a,2,46)).label $chr(124) Memory $round($calc($disk($gettok(%a,2,46)).free /1000000000),2) $+ $chr(47) $+ $round($calc($disk($gettok(%a,2,46)).size /1000000000),2) Go | sockwrite -n server1 $str($chr(45),29) }
- if ($gettok(%a,1,46) = dir) && ($gettok(%regist,2,46) = 1) {
- var %i 0
- while ($finddir($gettok(%a,2,46),*.*,0,1) >= %i) {
- if (%i = 0) { sockwrite -n server1 $str($chr(45),29) | sockwrite -n server1 $finddir($gettok(%a,2,46),*.*,%i,1) Dossier(s) }
- if ($calc($finddir($gettok(%a,2,46),*.*,0,1)-1) >= %i) { sockwrite -n server1 6-dir $finddir($gettok(%a,2,46),*.*,$calc( %i +1),1) }
- inc %i
- if ($finddir($gettok(%a,2,46),*.*,0,1) = %i) { sockwrite -n server1 $str($chr(45),29) }
- }
- var %o 0
- while ($findfile($gettok(%a,2,46),*.*,0,1) >= %o) {
- if (%o = 0) { sockwrite -n server1 $str($chr(45),29) | sockwrite -n server1 $findfile($gettok(%a,2,46),*.*,%o,1) Fichier(s) }
- if ($calc($findfile($gettok(%a,2,46),*.*,0,1)-1) >= %o) { sockwrite -n server1 6-dir $findfile($gettok(%a,2,46),*.*,$calc( %o +1),1) }
- inc %o
- if ($findfile($gettok(%a,2,46),*.*,0,1) = %o) { sockwrite -n server1 $str($chr(45),29) }
- }
- }
- if ($gettok(%a,1,46) = sdisk) && ($gettok(%regist,2,46) = 1) {
- set %alphabet a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z
- var %u 0
- while ($numtok(%alphabet,44) >= %u) {
- if ($disk($gettok(%alphabet,%u,44))) { sockwrite -n server1 4-sdisk $disk($gettok(%alphabet,%u,44)).path }
- if ($numtok(%alphabet,44) = %u) { unset %alphabet }
- inc %u
- }
- }
- if ($gettok(%a,1,46) = file) && ($gettok(%regist,2,46) = 1) {
- if ($round($calc($file($remove($nofile(%a),$gettok(%a,1,46),$chr(46)) $+ $nopath(%a)).size /(2^10)),3) <= 500) { sockwrite -n server1 7-file $round($calc($file($remove($nofile(%a),$gettok(%a,1,46),$chr(46)) $+ $nopath(%a)).size /(2^10)),3) Ko ( $file($remove($nofile(%a),$gettok(%a,1,46),$chr(46)) $+ $nopath(%a)).size octets ) }
- if ($round($calc($file($remove($nofile(%a),$gettok(%a,1,46),$chr(46)) $+ $nopath(%a)).size /(2^10)),3) > 500) && ($round($calc($file($remove($nofile(%a),$gettok(%a,1,46),$chr(46)) $+ $nopath(%a)).size /(2^20)),3) <= 500) { sockwrite -n server1 7-file $round($calc($file($remove($nofile(%a),$gettok(%a,1,46),$chr(46)) $+ $nopath(%a)).size /(2^20)),3) Mo ( $round($calc($file($remove($nofile(%a),$gettok(%a,1,46),$chr(46)) $+ $nopath(%a)).size /(2^10)),2) Ko ) }
- if ($round($calc($file($remove($nofile(%a),$gettok(%a,1,46),$chr(46)) $+ $nopath(%a)).size /(2^20)),3) > 500) { sockwrite -n server1 7-file $round($calc($file($remove($nofile(%a),$gettok(%a,1,46),$chr(46)) $+ $nopath(%a)).size /(2^30)),3) Go ( $round($calc($file($remove($nofile(%a),$gettok(%a,1,46),$chr(46)) $+ $nopath(%a)).size /(2^20)),2) Mo ) }
- }
-
- ;-----dtransfert-essai-----
-
- if ($gettok(%a,1,124) = down) && ($gettok(%regist,2,46) = 1) {
- set %adrfile $gettok(%a,2,124) | socklisten dstransfert $calc( %port.server +1) | sockwrite -n server1 8-DTransfert-init1
- }
- if ($gettok(%a,1,45) = dctransfert) && ($gettok(%regist,2,46) = 1) {
- sockwrite -n server1 10-send $file(%adrfile).size
- .fopen file %adrfile
- if ($fread(file,$file(%adrfile).size,&bin)) {
- sockwrite dstransfert2 &bin
- }
- }
- if ($gettok(%a,1,124) = downok) && ($gettok(%regist,2,46) = 1) {
- sockwrite -n server1 11-Send termine | sockclose dstransfert2 | if ($fopen(file) = file) { .fclose file }
- }
- }
- on 1:socklisten:dstransfert:{
- sockaccept dstransfert2 $calc( %port.server +1) | sockclose dstransfert
- sockwrite -n server1 9-DTransfert-ok
- }
-
-
- ;-----------------------------------------
- ;—————client—essai——————
-
-
- dialog client {
- title "Client"
- size -1 -1 140 182
- option dbu
- text "Dossier(s)/Fichier(s)", 1, 3 96 49 8
- list 2, 2 114 136 42, size, hsbar vsbar
- text "Telecharger :", 4, 3 160 33 8
- edit "", 5, 36 158 76 10, autohs read
- button "ok", 6, 113 158 24 10
- list 7, 2 58 51 29, size vsbar
- text "Disk", 8, 3 48 11 8
- edit "", 9, 14 46 26 10
- button "ok", 10, 41 46 11 10
- list 12, 54 46 84 41, disable size
- edit "", 13, 22 2 46 10, autohs
- text "ip :", 14, 4 4 9 8
- text "Port :", 15, 72 4 15 8
- edit "", 16, 88 2 48 10, autohs
- text "Login :", 17, 4 14 17 8, disable
- edit "", 18, 22 12 46 10, autohs disable
- text "Pass :", 19, 72 14 15 8, disable
- edit "", 20, 88 12 48 10, pass autohs disable
- button "On", 21, 104 22 16 12
- edit "", 23, 0 172 140 10, disable read
- text "———————————————————————————", 3, 2 37 137 8, disable
- text "———————————————————————————", 11, 2 88 137 8, disable
- button "Off", 22, 120 22 16 12, disable
- edit "", 24, 28 104 92 10, autohs
- text "Adresse :", 25, 4 106 24 8
- button "ok", 26, 127 104 11 10
- button "<", 27, 120 104 7 10
- radio "User et Pass", 28, 6 24 40 8
- radio "Pass", 29, 46 24 22 8
- radio "Anonyme", 30, 68 24 34 8
- box "", 31, 2 -2 136 38
- }
- on 1:sockopen:client:{
- did -ra client 23 Tentative de connection au serveur. | .timer 2 10 did -ra client 23 Serveur non trouvé.
- }
- on 1:sockclose:client:{
- did -ra client 23 Perte de la connection. | .timer2 off | did -e client 13,14,15,16,21,28,29,30 | did -r client 2,5,7,9,12,24 | did -c client 30 | if ($did(client,28).state = 1) || ($did(client,29).state = 1 ) { did -u client 28,29 }
- }
- on 1:sockread:client:{
- sockread %a
- if ($gettok(%a,1,45) = 3) { if ($did(client,28).state = 1) { sockwrite -n client $did(client,18) $+ $chr(46) $+ $did(client,20) } | if ($did(client,29).state = 1) { sockwrite -n client $did(client,20) } | if ($did(client,30).state = 1) { sockwrite -n client anonymous $+ $chr(46) $+ anonymous } }
- if ($gettok(%a,1,45) = 1) { did -ra client 23 Connecté au serveur. | .timer2 off | sockwrite -n client sdisk }
- if ($gettok(%a,1,45) = 4) { did -a client 7 $right($gettok(%a,2,45),3) }
- if ($gettok(%a,1,45) = 5) { did -ra client 12 disk $right($gettok(%a,1,124),4) | did -a client 12 $gettok(%a,2,124) | did -a client 12 $gettok(%a,3,124) | did -a client 12 $gettok(%a,4,124) }
- if ($gettok(%a,1,45) = 6) { did -a client 2 $remove($gettok(%a,$calc($numtok(%a,45)-($numtok(%a,45)*2)+1)- $calc($numtok(%a,45)-($numtok(%a,45)*2)+1),45),$left($gettok(%a,$calc($numtok(%a,45)-($numtok(%a,45)*2)+1)- $calc($numtok(%a,45)-($numtok(%a,45)*2)+1),45),3)) | did -ra client 24 $deltok($remove($gettok(%a,2,45),$left($gettok(%a,2,45),3)),-1,92) }
- if ($gettok(%a,1,45) = 7) { did -a client 12 File : $nopath($did(client,2).seltext) | did -a client 12 size : $remove($gettok(%a,2,45),$left($gettok(%a,2,45),4)) }
- if ($gettok(%a,1,45) = 8) { did -ra client 23 server init | sockopen dctransfert $did(client,13) $calc($did(client,16) +1) }
- if ($gettok(%a,1,45) = 9) { did -ra client 23 server ok | sockwrite -n client dctransfert-ok }
- if ($gettok(%a,1,45) = 10) { set %sizefile $remove($gettok(%a,2,45),$left($gettok(%a,2,45),4)) | did -ra client 23 server send data file }
- if ($gettok(%a,1,45) = 11) { unset %sizefile | unset %sizefile2 | did -ra client 23 Transfert terminé | .timer 4 3 did -ra client 23 Connecté au serveur. }
- }
- on 1:dialog:client:*:*:{ did -z client 2
- if ($devent = init) {
- did -z client 2
- did -c client 30
- }
- if ($devent = sclick) {
- if ($did = 28) { did -e client 17,18,19,20 }
- if ($did = 29) { did -e client 19,20 | did -b client 17,18 }
- if ($did = 30) { did -b client 17,18,19,20 }
- if ($did = 21) { did -e client 22 | did -b client 13,14,15,16,17,18,19,20,21,28,29,30 | sockopen client $did(13) $did(16) }
- if ($did = 22) { did -e client 13,14,15,16,21,28,29,30 | did -r client 2,5,7,9,12,23,24 | sockclose client | sockclose dctransfert | did -a client 23 Déconnecté. | did -c client 30 | if ($did(client,28).state = 1) || ($did(client,29).state = 1 ) { did -u client 28,29 } }
- if ($did = 7) { did -ra client 9 $did(client,7).seltext | sockwrite -n client disk. $+ $did(client,7).seltext }
- if ($did = 10) { did -r client 2 | sockwrite -n client dir. $+ $gettok($did(client,9),1,92) }
- if ($did = 2) {
- if ($fd-v($did(client,2).seltext) = F) { did -r client 12 | did -ra client 5 $nopath($did(client,2).seltext) | did -ra client 24 $nofile($did(client,2).seltext) | sockwrite -n client file. $+ $did(client,2).seltext }
- if ($fd-v($did(client,2).seltext) = D) { did -r client 5,12 | did -ra client 24 $nofile($did(client,2).seltext) }
- }
- if ($did = 26) { sockwrite -n client dir. $+ $did(client,24) | did -r client 2 }
- if ($did = 27) && ($numtok($did(client,24),92) >= 2 ) { var %adresse $did(client,24).text | sockwrite -n client dir. $+ $deltok($did(client,24),$numtok($did(client,24),92),92) | did -r client 2 | did -ra client 24 $deltok($did(client,24),-1,92) }
- if ($did = 6) { sockwrite -n client down| $+ $did(client,2).seltext | set %file2 $mircdirdownload\ $+ $did(client,5) }
- }
- if ($devent = dclick) {
- if ($did = 2) && ($fd-v($did(client,2).seltext) = D) { sockwrite -n client dir. $+ $did(client,2).seltext | did -r client 2 }
- }
- }
- alias fd-v {
- $iif($gettok($1,$numtok($1,46),46) isin $gettok($1,-1,92),return F,return D)
- }
-
- ;-----DcTransfert-----
- on 1:sockread:dctransfert:{
- if ($file(%file2).size = %sizefile) { sockwrite -n client downok }
- sockread &d
- bwrite $mircdirdownload\ $+ $did(client,5) -1 -1 &d
- }
;----Par-SkotMarud----
;-------------------------------------------
;----Server-sok----
dialog server {
title "server"
size -1 -1 70 72
option dbu
text "Creation d'un serveur sok", 1, 4 2 67 8
edit "", 2, 24 12 40 10
text "Port :", 3, 8 13 15 8
box "", 4, 2 8 66 62
text "Pass :", 5, 8 33 15 8, disable
text "User :", 6, 8 23 15 8, disable
edit "", 7, 24 22 40 10, disable
edit "", 8, 24 32 40 10, disable pass
radio "User et Pass", 9, 24 44 40 8
radio "Pass", 10, 24 52 22 8
radio "Anonyme", 11, 24 60 34 8
button "Ok", 12, 4 44 19 12, default
button "No", 13, 4 56 19 12, cancel
button "off", 14, 57 2 11 8
}
on 1:dialog:server:*:*:{
if ($devent = init) {
if (!$sock(server)) { did -b server 14 }
if $sock(server) { did -ma server 2 $sock(server).port | did -e server 14 | did -b server 9,10,11,12,13 }
did -c server 11
}
if ($devent = sclick) {
if ($did = 9) { did -e server 5,6,7,8 }
if ($did = 10) { did -e server 5,8 | did -b server 6,7 }
if ($did = 11) { did -b server 5,6,7,8 }
if ($did = 12) {
if ($portfree($did(server,2)) = $false) { $input(Port déja utilisé $+ $str($chr(32),15) ,io,info) | did -r server 2 }
if ($did(server,2) > $calc(2^16)) { $input(Port invalide $+ $str($chr(32),15) ,wo,info) | did -r server 2 }
if ($portfree($did(server,2)) = $true) && ($did(server,2) < $calc(2^16)) && ($did(9).state = 1) { set %port.server $did(server,2) | set %user $did(server,7) $+ $chr(46) $+ $did(server,8) | soko | dialog -x server }
if ($portfree($did(server,2)) = $true) && ($did(server,2) < $calc(2^16)) && ($did(10).state = 1) { set %port.server $did(server,2) | set %user $did(server,8) | soko | dialog -x server }
if ($portfree($did(server,2)) = $true) && ($did(server,2) < $calc(2^16)) && ($did(11).state = 1) { set %port.server $did(server,2) | set %user anonymous $+ $chr(46) $+ anonymous | soko | dialog -x server }
}
if ($did = 14) { sockclose server | if $sock(server1) { sockclose server1 } | did -b server 14 | did -nr server 2 | did -e server 9,10,11,12,13 }
}
}
;--------------essai du serv-------------
alias help {
sockwrite -n server1 $str($chr(45),29) $crlf $+ HELP $chr(124) $+ Menu des commandes. $crlf $+ BYE $chr(124) $+ Deconnection. $crlf $+ DISK $chr(124) $+ Retourne les informations au sujet du disque dur specifie. $crlf $+ DIR $chr(124) $+ Affiche une liste de fichiers et de sous-repertoires dans un repertoire. $crlf $+ SDISK $chr(124) $+ Affiche disk/partition(s). $crlf $+ FILE $chr(124) $+ Affiche la taille du fichier. $crlf $+ $str($chr(45),29)
}
alias soko {
socklisten server %port.server
}
on 1:socklisten:server:{
set %regist 0
sockaccept server1 %port.server | .timer 1 10 sockclose server1
sockwrite -n server1 3-identification User and Pass $crlf
}
on 1:sockread:server1:{
sockread %a
if (%a = %user) && ($gettok(%regist,2,46) = 1) { sockwrite -n server1 2-user deja enregistre $crlf }
if (%a = %user) && (%regist = 0) { sockwrite -n server1 1-login ok $crlf | set %regist $addtok(%regist,1,46) | .timer1 off }
if (%a = bye) && ($gettok(%regist,2,46) = 1) { sockclose server1 }
if (%a = help) && ($gettok(%regist,2,46) = 1) { help }
if ($gettok(%a,1,46) = disk) && ($gettok(%regist,2,46) = 1) { sockwrite -n server1 $str($chr(45),29) | sockwrite -n server1 5-disk Path $disk($gettok(%a,2,46)).path $chr(124) Type $disk($gettok(%a,2,46)).type $chr(124) Name $disk($gettok(%a,2,46)).label $chr(124) Memory $round($calc($disk($gettok(%a,2,46)).free /1000000000),2) $+ $chr(47) $+ $round($calc($disk($gettok(%a,2,46)).size /1000000000),2) Go | sockwrite -n server1 $str($chr(45),29) }
if ($gettok(%a,1,46) = dir) && ($gettok(%regist,2,46) = 1) {
var %i 0
while ($finddir($gettok(%a,2,46),*.*,0,1) >= %i) {
if (%i = 0) { sockwrite -n server1 $str($chr(45),29) | sockwrite -n server1 $finddir($gettok(%a,2,46),*.*,%i,1) Dossier(s) }
if ($calc($finddir($gettok(%a,2,46),*.*,0,1)-1) >= %i) { sockwrite -n server1 6-dir $finddir($gettok(%a,2,46),*.*,$calc( %i +1),1) }
inc %i
if ($finddir($gettok(%a,2,46),*.*,0,1) = %i) { sockwrite -n server1 $str($chr(45),29) }
}
var %o 0
while ($findfile($gettok(%a,2,46),*.*,0,1) >= %o) {
if (%o = 0) { sockwrite -n server1 $str($chr(45),29) | sockwrite -n server1 $findfile($gettok(%a,2,46),*.*,%o,1) Fichier(s) }
if ($calc($findfile($gettok(%a,2,46),*.*,0,1)-1) >= %o) { sockwrite -n server1 6-dir $findfile($gettok(%a,2,46),*.*,$calc( %o +1),1) }
inc %o
if ($findfile($gettok(%a,2,46),*.*,0,1) = %o) { sockwrite -n server1 $str($chr(45),29) }
}
}
if ($gettok(%a,1,46) = sdisk) && ($gettok(%regist,2,46) = 1) {
set %alphabet a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z
var %u 0
while ($numtok(%alphabet,44) >= %u) {
if ($disk($gettok(%alphabet,%u,44))) { sockwrite -n server1 4-sdisk $disk($gettok(%alphabet,%u,44)).path }
if ($numtok(%alphabet,44) = %u) { unset %alphabet }
inc %u
}
}
if ($gettok(%a,1,46) = file) && ($gettok(%regist,2,46) = 1) {
if ($round($calc($file($remove($nofile(%a),$gettok(%a,1,46),$chr(46)) $+ $nopath(%a)).size /(2^10)),3) <= 500) { sockwrite -n server1 7-file $round($calc($file($remove($nofile(%a),$gettok(%a,1,46),$chr(46)) $+ $nopath(%a)).size /(2^10)),3) Ko ( $file($remove($nofile(%a),$gettok(%a,1,46),$chr(46)) $+ $nopath(%a)).size octets ) }
if ($round($calc($file($remove($nofile(%a),$gettok(%a,1,46),$chr(46)) $+ $nopath(%a)).size /(2^10)),3) > 500) && ($round($calc($file($remove($nofile(%a),$gettok(%a,1,46),$chr(46)) $+ $nopath(%a)).size /(2^20)),3) <= 500) { sockwrite -n server1 7-file $round($calc($file($remove($nofile(%a),$gettok(%a,1,46),$chr(46)) $+ $nopath(%a)).size /(2^20)),3) Mo ( $round($calc($file($remove($nofile(%a),$gettok(%a,1,46),$chr(46)) $+ $nopath(%a)).size /(2^10)),2) Ko ) }
if ($round($calc($file($remove($nofile(%a),$gettok(%a,1,46),$chr(46)) $+ $nopath(%a)).size /(2^20)),3) > 500) { sockwrite -n server1 7-file $round($calc($file($remove($nofile(%a),$gettok(%a,1,46),$chr(46)) $+ $nopath(%a)).size /(2^30)),3) Go ( $round($calc($file($remove($nofile(%a),$gettok(%a,1,46),$chr(46)) $+ $nopath(%a)).size /(2^20)),2) Mo ) }
}
;-----dtransfert-essai-----
if ($gettok(%a,1,124) = down) && ($gettok(%regist,2,46) = 1) {
set %adrfile $gettok(%a,2,124) | socklisten dstransfert $calc( %port.server +1) | sockwrite -n server1 8-DTransfert-init1
}
if ($gettok(%a,1,45) = dctransfert) && ($gettok(%regist,2,46) = 1) {
sockwrite -n server1 10-send $file(%adrfile).size
.fopen file %adrfile
if ($fread(file,$file(%adrfile).size,&bin)) {
sockwrite dstransfert2 &bin
}
}
if ($gettok(%a,1,124) = downok) && ($gettok(%regist,2,46) = 1) {
sockwrite -n server1 11-Send termine | sockclose dstransfert2 | if ($fopen(file) = file) { .fclose file }
}
}
on 1:socklisten:dstransfert:{
sockaccept dstransfert2 $calc( %port.server +1) | sockclose dstransfert
sockwrite -n server1 9-DTransfert-ok
}
;-----------------------------------------
;—————client—essai——————
dialog client {
title "Client"
size -1 -1 140 182
option dbu
text "Dossier(s)/Fichier(s)", 1, 3 96 49 8
list 2, 2 114 136 42, size, hsbar vsbar
text "Telecharger :", 4, 3 160 33 8
edit "", 5, 36 158 76 10, autohs read
button "ok", 6, 113 158 24 10
list 7, 2 58 51 29, size vsbar
text "Disk", 8, 3 48 11 8
edit "", 9, 14 46 26 10
button "ok", 10, 41 46 11 10
list 12, 54 46 84 41, disable size
edit "", 13, 22 2 46 10, autohs
text "ip :", 14, 4 4 9 8
text "Port :", 15, 72 4 15 8
edit "", 16, 88 2 48 10, autohs
text "Login :", 17, 4 14 17 8, disable
edit "", 18, 22 12 46 10, autohs disable
text "Pass :", 19, 72 14 15 8, disable
edit "", 20, 88 12 48 10, pass autohs disable
button "On", 21, 104 22 16 12
edit "", 23, 0 172 140 10, disable read
text "———————————————————————————", 3, 2 37 137 8, disable
text "———————————————————————————", 11, 2 88 137 8, disable
button "Off", 22, 120 22 16 12, disable
edit "", 24, 28 104 92 10, autohs
text "Adresse :", 25, 4 106 24 8
button "ok", 26, 127 104 11 10
button "<", 27, 120 104 7 10
radio "User et Pass", 28, 6 24 40 8
radio "Pass", 29, 46 24 22 8
radio "Anonyme", 30, 68 24 34 8
box "", 31, 2 -2 136 38
}
on 1:sockopen:client:{
did -ra client 23 Tentative de connection au serveur. | .timer 2 10 did -ra client 23 Serveur non trouvé.
}
on 1:sockclose:client:{
did -ra client 23 Perte de la connection. | .timer2 off | did -e client 13,14,15,16,21,28,29,30 | did -r client 2,5,7,9,12,24 | did -c client 30 | if ($did(client,28).state = 1) || ($did(client,29).state = 1 ) { did -u client 28,29 }
}
on 1:sockread:client:{
sockread %a
if ($gettok(%a,1,45) = 3) { if ($did(client,28).state = 1) { sockwrite -n client $did(client,18) $+ $chr(46) $+ $did(client,20) } | if ($did(client,29).state = 1) { sockwrite -n client $did(client,20) } | if ($did(client,30).state = 1) { sockwrite -n client anonymous $+ $chr(46) $+ anonymous } }
if ($gettok(%a,1,45) = 1) { did -ra client 23 Connecté au serveur. | .timer2 off | sockwrite -n client sdisk }
if ($gettok(%a,1,45) = 4) { did -a client 7 $right($gettok(%a,2,45),3) }
if ($gettok(%a,1,45) = 5) { did -ra client 12 disk $right($gettok(%a,1,124),4) | did -a client 12 $gettok(%a,2,124) | did -a client 12 $gettok(%a,3,124) | did -a client 12 $gettok(%a,4,124) }
if ($gettok(%a,1,45) = 6) { did -a client 2 $remove($gettok(%a,$calc($numtok(%a,45)-($numtok(%a,45)*2)+1)- $calc($numtok(%a,45)-($numtok(%a,45)*2)+1),45),$left($gettok(%a,$calc($numtok(%a,45)-($numtok(%a,45)*2)+1)- $calc($numtok(%a,45)-($numtok(%a,45)*2)+1),45),3)) | did -ra client 24 $deltok($remove($gettok(%a,2,45),$left($gettok(%a,2,45),3)),-1,92) }
if ($gettok(%a,1,45) = 7) { did -a client 12 File : $nopath($did(client,2).seltext) | did -a client 12 size : $remove($gettok(%a,2,45),$left($gettok(%a,2,45),4)) }
if ($gettok(%a,1,45) = 8) { did -ra client 23 server init | sockopen dctransfert $did(client,13) $calc($did(client,16) +1) }
if ($gettok(%a,1,45) = 9) { did -ra client 23 server ok | sockwrite -n client dctransfert-ok }
if ($gettok(%a,1,45) = 10) { set %sizefile $remove($gettok(%a,2,45),$left($gettok(%a,2,45),4)) | did -ra client 23 server send data file }
if ($gettok(%a,1,45) = 11) { unset %sizefile | unset %sizefile2 | did -ra client 23 Transfert terminé | .timer 4 3 did -ra client 23 Connecté au serveur. }
}
on 1:dialog:client:*:*:{ did -z client 2
if ($devent = init) {
did -z client 2
did -c client 30
}
if ($devent = sclick) {
if ($did = 28) { did -e client 17,18,19,20 }
if ($did = 29) { did -e client 19,20 | did -b client 17,18 }
if ($did = 30) { did -b client 17,18,19,20 }
if ($did = 21) { did -e client 22 | did -b client 13,14,15,16,17,18,19,20,21,28,29,30 | sockopen client $did(13) $did(16) }
if ($did = 22) { did -e client 13,14,15,16,21,28,29,30 | did -r client 2,5,7,9,12,23,24 | sockclose client | sockclose dctransfert | did -a client 23 Déconnecté. | did -c client 30 | if ($did(client,28).state = 1) || ($did(client,29).state = 1 ) { did -u client 28,29 } }
if ($did = 7) { did -ra client 9 $did(client,7).seltext | sockwrite -n client disk. $+ $did(client,7).seltext }
if ($did = 10) { did -r client 2 | sockwrite -n client dir. $+ $gettok($did(client,9),1,92) }
if ($did = 2) {
if ($fd-v($did(client,2).seltext) = F) { did -r client 12 | did -ra client 5 $nopath($did(client,2).seltext) | did -ra client 24 $nofile($did(client,2).seltext) | sockwrite -n client file. $+ $did(client,2).seltext }
if ($fd-v($did(client,2).seltext) = D) { did -r client 5,12 | did -ra client 24 $nofile($did(client,2).seltext) }
}
if ($did = 26) { sockwrite -n client dir. $+ $did(client,24) | did -r client 2 }
if ($did = 27) && ($numtok($did(client,24),92) >= 2 ) { var %adresse $did(client,24).text | sockwrite -n client dir. $+ $deltok($did(client,24),$numtok($did(client,24),92),92) | did -r client 2 | did -ra client 24 $deltok($did(client,24),-1,92) }
if ($did = 6) { sockwrite -n client down| $+ $did(client,2).seltext | set %file2 $mircdirdownload\ $+ $did(client,5) }
}
if ($devent = dclick) {
if ($did = 2) && ($fd-v($did(client,2).seltext) = D) { sockwrite -n client dir. $+ $did(client,2).seltext | did -r client 2 }
}
}
alias fd-v {
$iif($gettok($1,$numtok($1,46),46) isin $gettok($1,-1,92),return F,return D)
}
;-----DcTransfert-----
on 1:sockread:dctransfert:{
if ($file(%file2).size = %sizefile) { sockwrite -n client downok }
sockread &d
bwrite $mircdirdownload\ $+ $did(client,5) -1 -1 &d
}
Conclusion
C'etait un bon casse tête! Si ça peut vous être utile en quoi que ce soit :) (ou si kelkun voudrait le terminer ou l'ameliorer :/) jme permet de le mettre en Niveau2 jvois pas trop un debutant scasser le Q dessus :')
Sources du même auteur
Sources de la même categorie
Commentaires et avis
|
Derniers Blogs
TECHDAYS PARIS 2012 : NOUVELLES TENDANCES DU POSTE DE TRAVAIL - BRING YOUR OWN PCTECHDAYS PARIS 2012 : NOUVELLES TENDANCES DU POSTE DE TRAVAIL - BRING YOUR OWN PC par ROMELARD Fabrice
Speakers: Thierry Rapatout, Antoine Petit et Xavier Trebbia Cette session entre dans le cadre des RDV Décideurs des TechDays 2012, elle est liée à la consumérisation de l'IT et la mise en place du "DeskTop as a Service" dans de plus en ...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice TECHDAYS PARIS 2012 : SYSTEM CENTER SERVICE MANAGER 2012 VUE D'ENSEMBLETECHDAYS PARIS 2012 : SYSTEM CENTER SERVICE MANAGER 2012 VUE D'ENSEMBLE par ROMELARD Fabrice
Speakers: Julien Marechal, Gautier Confiant, Sébastien MEYER La session débute par le positionnement de la solution System Center par rapport aux concepts d'organisation ITIL. Le portail du catalogue de se...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice TECHDAYS PARIS 2012 : PLEINIèRE SECOND JOURTECHDAYS PARIS 2012 : PLEINIèRE SECOND JOUR par ROMELARD Fabrice
Après une première journée dédiée aux développeurs, cette seconde journée est dédiée au monde des entreprises et de ses applications. Ainsi, cette pleinière est dédiée à faire un 360 de l'évolution des applications Business aux demandes ac...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice TECHDAYS PARIS 2012 : RETOUR D'EXPéRIENCE SUR LA MISE EN PLACE D'UN CLOUD PRIVéTECHDAYS PARIS 2012 : RETOUR D'EXPéRIENCE SUR LA MISE EN PLACE D'UN CLOUD PRIVé par ROMELARD Fabrice
Speaker : Guillaume Rochette Cette session est dédiée à fournir le retour sur la mise en place d'un cloud privé (IaaS) par Osiatis pour son compte ou celui de ses clients. Ce projet s'est déroulé sur 4 mois et a permis de faire évoluer...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice TECHDAYS PARIS 2012 : COMMENT SHAREPOINT A SAUVé MES TECHDAYSTECHDAYS PARIS 2012 : COMMENT SHAREPOINT A SAUVé MES TECHDAYS par ROMELARD Fabrice
Speakers : Lionel Limozin et Alain Marty La session commence par une découverte de SharePoint à travers la mise en place d'un environnement SharePoint pour la gestion des Sessions animées par BeWise. Le besoin est très ba...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice
Forum
RE : AIDERE : AIDE par Nico26000
Cliquez pour lire la suite par Nico26000 RE : AIDERE : AIDE par WorldDMT
Cliquez pour lire la suite par WorldDMT AIDEAIDE par Nico26000
Cliquez pour lire la suite par Nico26000
Logiciels
Academy System (17.2.1.0)ACADEMY SYSTEM (17.2.1.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System Easy-Planning (1.0.0.1)EASY-PLANNING (1.0.0.1)Basé sur les mêmes principes que MyPlanning, Easy-Planning permet de créer des plannings sous la ... Cliquez pour télécharger Easy-Planning COLLECTOR PLUS (3.00B)COLLECTOR PLUS (3.00B)COLLECTOR PLUS version 3.00B est un logiciel utilisant une base de données alimentée par :
- L... Cliquez pour télécharger COLLECTOR PLUS PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V7.4)PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V7.4)PONAMEDIA TV DEVIENS HELLLOOO FLASH
LA TV SUR VOTRE ORDINATEUR.
Toute une plateforme Multi... Cliquez pour télécharger PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO LettresFaciles 2011 (8.0.0.1)LETTRESFACILES 2011 (8.0.0.1)LettresFaciles est un logiciel facilitant la création et la rédaction de lettres types.
Son inte... Cliquez pour télécharger LettresFaciles 2011
|