Re: [twsocket] Twsocket Problem over Internet.
Not correct. Please narow your question. Make it more specific. Describe your "problem". Try to apply the advice we gave to you in previous answers. Have you read the two article link I gave to you a few days ago ? We will not write the code for you. Regards, -- francois.pie...@overbyte.be The author of the freeware multi-tier middleware MidWare The author of the freeware Internet Component Suite (ICS) http://www.overbyte.be -Message d'origine- De : TWSocket [mailto:twsocket-boun...@lists.elists.org] De la part de Fatimire Envoyé : lundi 13 novembre 2017 21:31 À : ICS support mailing Objet : Re: [twsocket] Twsocket Problem over Internet. anything is wrong ? thank you everybody. Receiving... var Count : Integer; InString: string; begin with Sender as TClient do try if IsRcvBin then begin if not assigned(MS) then MS := TMemoryStream.Create; Count := Receive(@Buffer[1], BLOCK_SIZE); if Count <= 0 then //check if we received something Exit; // write the buffer to our memorystream MS.Write(Buffer, Count); if MS.Size = ExpectedStreamSize then //have we received whole stream Image2.Picture.Graphic.LoadFromStream(MS); Exit; end; InString := ReceiveStr; if (InString.StartsWith('IMAGE:')) then InString := InString.Substring(6); ExpectedStreamSize := StrToInt(InString); IsRcvBin := True;// we start receiving binary data LineMode := False; // so we put linemode off except end; end; -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] Twsocket Problem over Internet.
> anything is wrong ? Do you mean your code does not work correctly. We have made various suggestions about how it should be written to work correctly, but you have yet to implement any of them. Angus -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] Twsocket Problem over Internet.
anything is wrong ? thank you everybody. Receiving... var Count : Integer; InString: string; begin with Sender as TClient do try if IsRcvBin then begin if not assigned(MS) then MS := TMemoryStream.Create; Count := Receive(@Buffer[1], BLOCK_SIZE); if Count <= 0 then //check if we received something Exit; // write the buffer to our memorystream MS.Write(Buffer, Count); if MS.Size = ExpectedStreamSize then //have we received whole stream Image2.Picture.Graphic.LoadFromStream(MS); Exit; end; InString := ReceiveStr; if (InString.StartsWith('IMAGE:')) then InString := InString.Substring(6); ExpectedStreamSize := StrToInt(InString); IsRcvBin := True;// we start receiving binary data LineMode := False; // so we put linemode off except end; end; Sent from [ProtonMail](https://protonmail.ch), encrypted email based in Switzerland. > Original Message > Subject: Re: [twsocket] Twsocket Problem over Internet. > Local Time: November 13, 2017 11:48 AM > UTC Time: November 13, 2017 1:48 PM > From: wilfr...@mestdagh.biz > To: twsoc...@elists.org > > If you set the Addr property to '0.0.0.0' then TWSocket will listen on > all interfaces. > > Met vriendelijke groeten, > Wilfried Mestdagh > > Op 13-11-17 om 14:43 schreef Fatimire: > >> How i listen the wsocket to all interfaces? maybe my problem is this i have >> multiple interfaces. >> -- >> To unsubscribe or change your settings for TWSocket mailing list >> please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket >> Visit our website at http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] Twsocket Problem over Internet.
If you set the Addr property to '0.0.0.0' then TWSocket will listen on all interfaces. Met vriendelijke groeten, Wilfried Mestdagh Op 13-11-17 om 14:43 schreef Fatimire: How i listen the wsocket to all interfaces? maybe my problem is this i have multiple interfaces. -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] Twsocket Problem over Internet.
How i listen the wsocket to all interfaces? maybe my problem is this i have multiple interfaces. Sent from [ProtonMail](https://protonmail.ch), encrypted email based in Switzerland. > Original Message > Subject: Re: [twsocket] Twsocket Problem over Internet. > Local Time: November 13, 2017 11:28 AM > UTC Time: November 13, 2017 1:28 PM > From: fatim...@protonmail.com > To: ICS support mailing <twsocket@lists.elists.org> > > i dont why works on local network and not work in internet connection... > > Sent from [ProtonMail](https://protonmail.ch), encrypted email based in > Switzerland. > >> ---- Original Message ---- >> Subject: Re: [twsocket] Twsocket Problem over Internet. >> Local Time: November 11, 2017 9:01 AM >> UTC Time: November 11, 2017 11:01 AM >> From: francois.pie...@skynet.be >> To: 'ICS support mailing' <twsocket@lists.elists.org> >> >>> Your receiving is also likely to fail, LineMode should not be used when >>> you expect binary data, >>> >>> Agreed. >>> >>> and makes a program more complex than necessary swapping back and forward >>> while receiving, checking line end is not very hard. >>> >>> Disagreed. >>> What would be easier for Fatimire is to send the image length a single >>> integer (4 bytes is probably enough) instead of a text line. It is easier >>> because the length is fixed. When receiving, it is enough to check if the >>> first 4 bytes are received and the get the length without further parsing. >>> >>> The code should be written using pure event driven, without wait loops. >>> >>> Fatimire should read the following documentation: >>> http://wiki.overbyte.eu/wiki/index.php/Asynchronous_Paradigm >>> http://wiki.overbyte.eu/wiki/index.php/Sending_and_receiving_data >>> >>> -- >>> francois.pie...@overbyte.be >>> The author of the freeware multi-tier middleware MidWare >>> The author of the freeware Internet Component Suite (ICS) >>> http://www.overbyte.be >>> >>> -- >>> To unsubscribe or change your settings for TWSocket mailing list >>> please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket >>> Visit our website at http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] Twsocket Problem over Internet.
i dont why works on local network and not work in internet connection... Sent from [ProtonMail](https://protonmail.ch), encrypted email based in Switzerland. > Original Message > Subject: Re: [twsocket] Twsocket Problem over Internet. > Local Time: November 11, 2017 9:01 AM > UTC Time: November 11, 2017 11:01 AM > From: francois.pie...@skynet.be > To: 'ICS support mailing' <twsocket@lists.elists.org> > >> Your receiving is also likely to fail, LineMode should not be used when >> you expect binary data, >> >> Agreed. >> >> and makes a program more complex than necessary swapping back and forward >> while receiving, checking line end is not very hard. >> >> Disagreed. >> What would be easier for Fatimire is to send the image length a single >> integer (4 bytes is probably enough) instead of a text line. It is easier >> because the length is fixed. When receiving, it is enough to check if the >> first 4 bytes are received and the get the length without further parsing. >> >> The code should be written using pure event driven, without wait loops. >> >> Fatimire should read the following documentation: >> http://wiki.overbyte.eu/wiki/index.php/Asynchronous_Paradigm >> http://wiki.overbyte.eu/wiki/index.php/Sending_and_receiving_data >> >> -- >> francois.pie...@overbyte.be >> The author of the freeware multi-tier middleware MidWare >> The author of the freeware Internet Component Suite (ICS) >> http://www.overbyte.be >> >> -- >> To unsubscribe or change your settings for TWSocket mailing list >> please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket >> Visit our website at http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] Twsocket Problem over Internet.
> Your receiving is also likely to fail, LineMode should not be used when you expect binary data, Agreed. > and makes a program more complex than necessary swapping back and forward while receiving, checking line end is not very hard. Disagreed. What would be easier for Fatimire is to send the image length a single integer (4 bytes is probably enough) instead of a text line. It is easier because the length is fixed. When receiving, it is enough to check if the first 4 bytes are received and the get the length without further parsing. The code should be written using pure event driven, without wait loops. Fatimire should read the following documentation: http://wiki.overbyte.eu/wiki/index.php/Asynchronous_Paradigm http://wiki.overbyte.eu/wiki/index.php/Sending_and_receiving_data -- francois.pie...@overbyte.be The author of the freeware multi-tier middleware MidWare The author of the freeware Internet Component Suite (ICS) http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] Twsocket Problem over Internet.
> I try send by block and have the same problem. > Sleep(100); If you changed that to Sleep(5000) it would probably work, but very slowly As I said originally, you should be using the OnDataSent to determine when the data is sent successfully, not just waiting and assuming the internet is working perfectly and instantly. Your receiving is also likely to fail, LineMode should not be used when you expect binary data, and makes a program more complex than necessary swapping back and forward while receiving, checking line end is not very hard. And you need to loop to keep receiving until the whole image has been arrived, it might take minutes on a slow connection. And handle the connection breaking before it's complete. Angus -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] Twsocket Problem over Internet.
Hi ! Sending is OK although not optimal because of buffering. At least, be sure to no close the socket before the sending is done: TWSocket will buffer data for you (up to the amount of available ram space). It is bette as Angus said, to send by blocks. For receiving, you must first receive the line you send before the image, to get the image size. And then you must receive block by block until you get the whole image. You may switch TWSoket from line mode (for the line you sent with the image size) and the go back to binary mode to receive the rest block by block as you do. -- francois.pie...@overbyte.be The author of the freeware multi-tier middleware MidWare The author of the freeware Internet Component Suite (ICS) http://www.overbyte.be -Message d'origine- De : TWSocket [mailto:twsocket-boun...@lists.elists.org] De la part de Fatimire Envoyé : vendredi 10 novembre 2017 20:32 À : ICS support mailing Objet : [twsocket] Twsocket Problem over Internet. HI for all, i do a prototype to transfer a imagem overt internet with Twsocket, but in local network works fine, but when i test with a remote computer in internet connection the file is sended but dont receive or receive a image with lost collor. sending ... try FMS.Seek(0, soBeginning); Form10.wscktsrvr1.Client[0].SendStr('IMAGE:' + IntToStr(FMS.Size) + sLineBreak); Form10.wscktsrvr1.Client[0].Send(FMS.Memory, FMS.Size); finally Receiving ... if (FIsBiniary) then begin iCount := Socket3.Receive(FRcvd + FWritePtr, FFileSize - FWritePtr); Inc(FWritePtr, iCount); if (iCount = 0) then begin FIsBiniary := False; end; if FWritePtr = FFileSize then begin F := TMemoryStream.Create(); try F.Write(FRcvd[0], FFileSize); Memo1.Lines.Add('write'); finally oBMP := TBitmap.Create; f.Seek(0, soBeginning); oBMP.LoadFromStream(F); Image1.Picture.Assign(oBMP); FreeMem(FRcvd, FFileSize); FreeAndNil(oBMP); F.Free; end; FIsBiniary := False; Socket3.LineMode := True; end; Exit; end; sRcvBuf := Socket3.ReceiveStr.Trim; Memo1.Lines.Add(sRcvBuf); if (sRcvBuf.StartsWith('IMAGE001:')) then begin sRcvBuf := sRcvBuf.Substring(9); Memo1.Lines.Add('Size: ' + sRcvBuf); FFileSize := StrToIntDef(sRcvBuf, 0); FWritePtr := 0; GetMem(FRcvd, FFileSize); Socket3.LineMode := False; FIsBiniary := True; end; end; someone can help-me ? Sent from [ProtonMail](https://protonmail.ch), encrypted email based in Switzerland. -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] Twsocket Problem over Internet.
> HI for all, i do a prototype to transfer a imagem overt internet > with Twsocket, > but in local network works fine, but when i test with a remote > computer in internet connection > the file is sended but dont receive or receive a image with lost > collor. Your code assumes that Send() will cope with an unlimited amount of data, when there are limits due to the internal buffers. For large sizes, say over 32K, you need to send the data in blocks, waiting until each has been sent, before sending the next. This is illustrated in several sample applications, with each new block being sent when the OnDataSent event is called. Angus -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be