Giter Site home page Giter Site logo

passimplesockets's People

Contributors

warfley avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

passimplesockets's Issues

Not finding `ioctlsocket` and `FIONREAD` when compiling under Linux

Hi @Warfley,

looks like we have a smidge of an issue ๐Ÿ˜„ :

./simplesockets/simplesockets.pas(586,6) Error: (5000) Identifier not found "ioctlsocket"
./simplesockets/simplesockets.pas(586,30) Error: (5000) Identifier not found "FIONREAD"
simplesockets.pas(600) Fatal: (10026) There were 2 errors compiling module, stopping

This is for the latest(trunk) and 2 early stable versions: 2.0.12 and 2.2.2.

I've done a search and ioctlsocket is really only present under Windows, or am I wrong?

Cheers,
Gus

can't compile

Hi Warfley,

Compile error on Lazarus 2.2.3 (rev lazarus_2_2_2-47-g6c1bc2c78d) FPC 3.2.3 x86_64-linux-gtk2, debian bullseye


Hint: (11030) Start of reading config file /home/ngx/gue/laz/fpc/bin/x86_64-linux/fpc.cfg
Hint: (11031) End of reading config file /home/ngx/gue/laz/fpc/bin/x86_64-linux/fpc.cfg
Free Pascal Compiler version 3.2.3-651-g682c53ff6b [2022/07/13] for x86_64
Copyright (c) 1993-2021 by Florian Klaempfl and others
(1002) Target OS: Linux for x86-64
(3104) Compiling udpechoserver.pas
(3104) Compiling /home/ngx/gue/laz/_lib/PasSimpleSockets/simplesockets.pas
..........
/home/ngx/gue/laz/_lib/PasSimpleSockets/simplesockets.pas(348,78) Error: (4025) Incompatible type for arg no. 3: Got "^Int64", expected "pSockLen"
/home/ngx/gue/laz/fpc/units/x86_64-linux/rtl-extra/sockets.ppu:unixsock.inc(190,11) Hint: (5039) Found declaration: fpaccept(LongInt;psockaddr;pSockLen):LongInt;
/home/ngx/gue/laz/_lib/PasSimpleSockets/simplesockets.pas(382,105) Error: (4025) Incompatible type for arg no. 6: Got "^Int64", expected "pSockLen"
/home/ngx/gue/laz/fpc/units/x86_64-linux/rtl-extra/sockets.ppu:unixsock.inc(172,11) Hint: (5039) Found declaration: fprecvfrom(LongInt;Pointer;QWord;LongInt;psockaddr;pSockLen):Int64;
/home/ngx/gue/laz/_lib/PasSimpleSockets/simplesockets.pas(529,16) Error: (5000) Identifier not found "fp"
/home/ngx/gue/laz/_lib/PasSimpleSockets/simplesockets.pas(529,26) Fatal: (2003) Syntax error, ";" expected but "identifier FD_ZERO" found

Fatal: (1018) Compilation aborted


On Windows Lazarus 2.2.3 (rev lazarus_2_2_2-47-g6c1bc2c78d) FPC 3.2.3 i386-win32-win32/win64, it works

[Shameful Ask]: Implement WriteStrLn and ReadStrLn

Hey Frederic (@Warfley),

I could probably pull this off if I dedicate 5 hours to stumble in the dark and then find the solution, but I'm not really that good at sockets and I lack the expertise on sockets and their APIs. So I'm really afraid of introducing inefficiency into the code.

In my opinion you first have to chose between: CRLF, CR or LF and then stick to it no matter the OS's preference on how to terminate a line. I would have to have looksie on how Indy10 implements it's WriteLn to a socket just out of curiosity.

Once that's decided, the WriteStrLn would only be a call to WriteStr with the chosen line termination appended at the end.

Now, the issue is now the ReadStrLn... And I see two roads ahead:

  1. You do a read on a single byte basis until you hit the line termination and leave the level below to deal with the rest of the buffer.
    • This is where I feel that I would introduce inefficiency.
  2. You read in chunks of, let's say 1024, and search for the termination inside those chunks, but now you have the responsibility to manage the buffer.
    • This, from the quick read on the code, would imply a major overhaul to accommodate SimpleSockets new management of the buffer.

As you can see, I got the theory or at least the gist of it ๐Ÿ˜„
But then my implementation would be a bit sloppy, or introduce some nasty inefficiencies ๐Ÿ˜ž

So what do you think?

Cheers,
Gus

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.