strannik_nebes писал(а): Цель: отправка больших файлов по протоколу обмена.
Для отправки больших файлов, по моему, нужно использовать SharedStream.
Вот набрасал небольшой пример. Можно передать файлы более гигабайта...
Сервер
Add(MainForm,11176470,280,70) { Left=20 Top=105 Width=380 Height=161 Caption="Receive big file" Position=1 Point(onClose) link(onClose,11727965:doWork2,[]) } Add(TCP_Server,37674,357,126) { Port=130 DataType=3 Point(onError) Point(onProgress) link(onRead,12923094:doSeparateMT,[]) link(onConnect,7080087:doEvent1,[(403,139)(403,300)]) link(onDisconnect,7231487:doEvent1,[(410,146)(410,265)]) } Add(SharedStream,4764602,700,133) { CoreName="dsa" PageMem=160 Mode=1 Point(FileSize) link(onOpen,3538368:doCopy,[]) link(FileName,2178470:Result,[(706,124)(692,124)(692,173)(636,173)]) link(Offset,5706248:Offset,[(720,117)(685,117)(685,180)(496,180)]) link(Size,5706248:SizeMMF,[(727,124)(741,124)(741,194)(489,194)]) } Add(StreamCopy,3538368,777,133) { link(onCopy,1565907:doWork1,[(851,139)(851,293)]) link(Dest,4764602:Stream,[(783,124)(769,124)(769,173)(706,173)]) link(Source,5706248:Filepart,[(790,122)(818,122)(818,202)(482,202)]) } Add(StreamUnPack,5706248,469,126) { DataCount=#8:FileName|8:Filepart|7:SizeMMF|6:Offset|8:FileSize| link(onUnPack,11056289:doCompare,[]) } Add(MT_MultiData,12923094,420,126) { Count=1 link(onData1,5706248:doUnPack,[]) } Add(LED,10294395,455,280) { Left=315 Top=85 } Add(Hub,7231487,420,259) { OutCount=3 link(onEvent1,4764602:doClose,[(669,265)(669,153)]) link(onEvent2,1565907:doWork3,[(494,272)(494,307)]) link(onEvent3,10294395:doOff,[(445,279)(445,293)]) } Add(Label,7626178,959,273) { Left=95 Top=90 Width=130 Height=20 Caption="" } Add(StrCatDelim,2178470,630,133) { Delimiter="\" link(onStrCatDlm,4764602:doOpen,[]) link(Str1,9721491:Text,[(636,110)(349,110)(349,187)(188,187)]) link(Str2,5706248:FileName,[(643,124)(622,124)(622,173)(475,173)]) } Add(Label,16191510,119,231) { Left=15 Top=15 Width=240 Caption="Укажите папку для принятых файлов" } Add(Edit,9721491,182,140) { Left=5 Top=35 Width=325 Text="" ClearAfterEnter=1 link(onChange,4281014:doExists,[]) } Add(Button,15010227,98,140) { Left=335 Top=35 Width=20 Font=[MS Sans Serif,8,1,0,1] Cursor=2 TabOrder=-1 Caption="..." Data=Integer(6) link(onClick,15313214:doBrowse,[]) } Add(Browse,15313214,140,140) { NewStyle=0 link(onBrowse,9721491:doText,[]) } Add(DirTools,4281014,231,119) { Point(doExists) link(onOK,14169860:doEvent,[]) } Add(IndexToChanel,14169860,280,119) { link(onEvent1,10555517:doWork2,[]) link(onEvent2,37674:doOpen,[]) } Add(If_else,11056289,525,126) { Type=3 link(onTrue,6107069:doEvent1,[(564,132)(564,125)]) link(onFalse,2178470:doStrCatDlm,[]) link(Op1,5706248:FileSize,[(531,117)(517,117)(517,166)(503,166)]) link(Op2,4764602:FileSize,[(538,117)(573,117)(573,187)(727,187)]) } Add(Hub,6107069,581,119) { link(onEvent1,11727965:doWork3,[(606,125)(606,97)]) link(onEvent2,1565907:doWork2,[(606,132)(606,300)]) } Add(ChanelToIndex,1565907,861,287) { Count=4 link(onIndex,14016326:doGetString,[]) } Add(StrList,14016326,910,259) { Strings=#14:Приём файла...|11:Файл принят|17:Клиент отключился|17:Ожидание передачи|0:|0:| Point(doGetString) Point(onGetIndex) Point(onGetString) link(onGetString,7626178:doText,[]) } Add(Hub,7080087,413,294) { link(onEvent1,10294395:doOn,[]) link(onEvent2,1565907:doWork4,[(445,307)(445,314)]) } Add(HubEx,11727965,328,91) { Angle=1 link(onEvent,10555517:doWork1,[]) } Add(HubEx,10555517,328,119) { Angle=1 link(onEvent,37674:doClose,[(332,139)]) }
Клиент
Add(MainForm,11176470,560,280) { Left=20 Top=105 Width=377 Height=134 Caption="Send big file" Position=1 Point(onClose) link(onClose,9043421:doWork2,[(620,307)(620,314)]) } Add(ODialog,1786215,273,70) { link(onExecute,9721491:doText,[]) } Add(SharedStream,12437222,399,70) { CoreName="asd" PageMem=160 Point(FileOffset) Point(CountFileBlock) Point(FileSize) link(onOpen,15201884:doFor,[]) link(Offset,10512455:Result,[(419,61)(447,61)(447,138)(664,138)]) } Add(Edit,9721491,322,70) { Top=65 Width=325 Text="" ClearAfterEnter=1 link(onChange,12437222:doOpen,[]) } Add(Button,15010227,189,63) { Left=330 Top=65 Width=20 Font=[MS Sans Serif,8,1,0,1] Cursor=2 TabOrder=-1 Caption="..." Data=Integer(6) link(onClick,7649023:doEvent1,[]) } Add(For,15201884,483,70) { link(onEvent,639348:doEvent1,[]) link(onStop,12437222:doClose,[(522,83)(522,55)(382,55)(382,90)]) link(End,12437222:CountFileBlock,[(496,61)(475,61)(475,110)(433,110)]) } Add(EventFromData,12814098,273,266) { link(onEvent,3731920:doPart,[]) } Add(TCP_Client,52372,644,301) { Port=130 IP="127.0.0.1" DataType=3 Point(onError) Point(onProgress) link(onConnect,10294395:doOn,[(683,314)(683,328)]) link(onDisconnect,10294395:doOff,[]) } Add(Hub,639348,539,70) { link(onEvent1,8314133:doPack,[(564,76)(564,118)(389,118)(389,321)]) link(onEvent2,10512455:doOperation,[]) } Add(StreamPack,8314133,399,315) { DataCount=#8:FileName|8:Filepart|7:SizeMMF|6:Offset|8:FileSize| link(onPack,52372:doSend,[]) link(FileName,12814098:GetData,[(405,306)(279,306)]) link(Filepart,12437222:Stream,[(412,243)(405,243)]) link(SizeMMF,9575546:Var2,[]) link(Offset,13961555:Var2,[]) link(FileSize,12437222:FileSize,[(433,138)(440,138)]) } Add(GetDataEx,13961555,420,126) { link(Data,12437222:FileOffset,[]) } Add(FilePartElm,3731920,322,266) { link(onPart,12814098:doData,[(361,272)(361,258)(263,258)(263,272)]) link(FileName,9721491:Text,[]) } Add(Hub,7649023,238,63) { link(onEvent1,10512455:doClear,[(263,69)(263,41)(571,41)(571,90)]) link(onEvent2,1786215:doExecute,[]) } Add(GetDataEx,9575546,413,119) { link(Data,12437222:SizeMMF,[]) } Add(Math,10512455,658,77) { ResultType=0 Point(doClear) link(onResult,12437222:doRemapping,[(697,83)(697,48)(389,48)(389,83)]) link(Op1,13961555:Var3,[(664,68)(650,68)(650,131)]) link(Op2,9575546:Var3,[(671,61)(643,61)(643,124)]) } Add(LED,10294395,700,308) { Left=200 Top=10 } Add(Label,12900334,63,21) { Left=10 Top=35 Width=202 Height=17 Caption="Выбрать файл для отправки на сервер" } Add(Button,3343666,504,238) { Left=5 Top=10 Width=170 Caption="Соединидся с с сервером" Point(doCaption) link(onClick,3761722:doSwitch,[]) } Add(Switch,3761722,560,238) { DataOn=String(Отключится) DataOff=String(Подключится) Point(onOn) Point(onOff) link(onSwitch,3343666:doCaption,[(599,244)(599,230)(494,230)(494,244)]) link(onOn,52372:doOpen,[(634,251)(634,307)]) link(onOff,9043421:doWork1,[(627,258)]) } Add(HubEx,9043421,623,308) { link(onEvent,52372:doClose,[]) }
|