Re: [fpc-pascal] INVALID_SOCKET constant not defined for Linux

2017-03-28 Thread Ched
Most likely this is only because "socket < 0" is faster to write than "socket = -1" :-) And is probably faster to execute on most processors which offers a sign flag. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal

Re: [fpc-pascal] INVALID_SOCKET constant not defined for Linux

2017-03-28 Thread Ladislav Karrach
This technique is used in fcl-net which should be cross-platform. So I am right, when I say that also in Linux invald socket = -1 (in other words: in case of error syscall() returns always -1) Becuase in other place I see another test "if socket < 0 then ..." (which may mean that any negative v

Re: [fpc-pascal] INVALID_SOCKET constant not defined for Linux

2017-03-28 Thread Giuliano Colla
Il 28/03/2017 12:34, LacaK ha scritto: This technique is used in fcl-net which should be cross-platform. So I am right, when I say that also in Linux invald socket = -1 (in other words: in case of error syscall() returns always -1) Becuase in other place I see another test "if socket < 0 then ..

Re: [fpc-pascal] INVALID_SOCKET constant not defined for Linux

2017-03-28 Thread LacaK
Under *nix socket calls are just general runtime calls, and they use the same convention and constants for errorhandling as all other calls. As I know "nothing" about Linux, then it is safe to check?: socket := Sockets.FPSocket(...); if socket = -1 then // invalid socket returned due to error

Re: [fpc-pascal] INVALID_SOCKET constant not defined for Linux

2017-03-28 Thread Michael Van Canneyt
On Tue, 28 Mar 2017, LacaK wrote: Hi, I am porting application from Windows to Linux. I use Sockets unit. There is defined on Windows (and also on BeOS, FreeBSD, OS2): INVALID_SOCKET = TSocket(Not 0); // or -1 SOCKET_ERROR = -1; But not for Linux. Does it means, that result of unsuccess

Re: [fpc-pascal] INVALID_SOCKET constant not defined for Linux

2017-03-28 Thread Marco van de Voort
In our previous episode, LacaK said: > I am porting application from Windows to Linux. I use Sockets unit. > > There is defined on Windows (and also on BeOS, FreeBSD, OS2): >INVALID_SOCKET = TSocket(Not 0); // or -1 >SOCKET_ERROR = -1; > > But not for Linux. Does it means, that result of

Re: [fpc-pascal] WideStringReplace bug?

2017-03-28 Thread Lubos Pintes
Sorry I forgot the FPC version: 3.1.1 [2017/02/15] for i386 Dňa 28. 3. 2017 o 11:22 Lubos Pintes napísal(a): Hello,, I am developing a console program which receives input in UTF-8, but it is converted to WideString for communication with COM. I found a weird behaviour of the WideStringReplace, a

[fpc-pascal] WideStringReplace bug?

2017-03-28 Thread Lubos Pintes
Hello,, I am developing a console program which receives input in UTF-8, but it is converted to WideString for communication with COM. I found a weird behaviour of the WideStringReplace, and I extracted the small program below: program a; {$apptype console} uses SysUtils; var U: UTF8String;

[fpc-pascal] INVALID_SOCKET constant not defined for Linux

2017-03-28 Thread LacaK
Hi, I am porting application from Windows to Linux. I use Sockets unit. There is defined on Windows (and also on BeOS, FreeBSD, OS2): INVALID_SOCKET = TSocket(Not 0); // or -1 SOCKET_ERROR = -1; But not for Linux. Does it means, that result of unsuccessfull call to Sockets.FPSocket can be