Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
L ldpl
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 8
    • Issues 8
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Lartu
  • ldpl
  • Merge requests
  • !111

Closed
Created Jun 03, 2019 by Lartu@lartu🐕Maintainer
  • Report abuse
Report abuse

Basic TCP/IP commands: SEND, LISTEN, & REPLY

  • Overview 15
  • Commits 14
  • Changes 3

Created by: dvkt

This is one idea for how to approach #110. It adds SEND, LISTEN, and REPLY to LDPL as basic socket statements. It's not ready to be merged yet, but I wanted to open this to track progress.

Send statement:

SEND <TEXT-EXPR> TO <TEXT-EXPR> AT <NUMBER-EXPR> IN <TEXT-VAR>

This will open a TCP connection to host/port, send the data, read the response into a variable, then close the connection.

You can use it to make basic HTTP requests currently, but people will want persistent connections for stuff like IRC. So the next step is probably adding something like CONNECT TO <host> AT <port> and CLOSE CONNECTION TO <host> AT <port> to be used in conjunction with SEND.

Then if CONNECT has been called, SEND will re-use that connection and keep it open. Otherwise, it'll open and close a new connection.

Receive statement:

LISTEN ON <TEXT-EXPR> AT <NUMBER-EXPR> AND CALL <SUB-PROCEDURE> WITH <TEXT-VAR>

This starts a basic multi-client TCP server that uses select(). It can only read 1024 byte requests, so we'll have to increase that if we want to support stuff like HTTP POST. Otherwise it should work fine. Currently it closes all connections after sending data.

I, uh, wouldn't call this "industrial strength" or anything like that. But once we get it working right, it'll probably be okay for little dev servers.

Right now the request body is put into the <TEXT-VAR> so it can be accessed in the callback, but I'm going to change it to be a MAP. That way you can get information about the specific client that made the request and all that.

Reply statement:

REPLY WITH <TEXT-EXPR>

This can be used in the LISTEN callback. We may want to add a few more callback-specific statements in the future too, for managing the client connection.

Windows

The examples/echo.ldpl program should work on Linux and MacOS. I haven't added Windows support yet, but I am going to work on that next. It should be possible to have things work the same way.

That's it

I'll update this PR when I make more progress. Any thoughts on the syntax, approach, or other things we're gonna need?

Assignee
Assign to
Reviewer
Request review from
None
Milestone
None
Assign milestone
Time tracking
Source branch: github/fork/dvkt/send-listen-reply