Skip to content

feat: add Server.prototype.send()#192

Merged
MylesBorins merged 1 commit intomainfrom
server-send
Mar 16, 2026
Merged

feat: add Server.prototype.send()#192
MylesBorins merged 1 commit intomainfrom
server-send

Conversation

@MylesBorins
Copy link
Owner

Extract the UDP send implementation into a shared internal helper and use it from both Client and Server.

Add Server#send(message, port, host, callback?) so a bound server socket can send replies from the same port without monkey-patching Client methods.

Cover the new behavior with round-trip, in-handler reply, pre-listening error, and closed-socket promise rejection tests, and extend the TypeScript fixtures to exercise the new API.

Closes: #190

Extract the UDP send implementation into a shared internal helper and use it from both Client and Server.

Add Server#send(message, port, host, callback?) so a bound server socket can send replies from the same port without monkey-patching Client methods.

Cover the new behavior with round-trip, in-handler reply, pre-listening error, and closed-socket promise rejection tests, and extend the TypeScript fixtures to exercise the new API.

Closes: #190
@MylesBorins MylesBorins merged commit a467a34 into main Mar 16, 2026
15 checks passed
@MylesBorins MylesBorins deleted the server-send branch March 16, 2026 02:11
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 39ee7a31d6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +167 to +171
cb(error);
return;
}

throw error;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reject pre-listening sends instead of throwing synchronously

In the no-callback form, send() is documented/used as a Promise API, but this branch throws before any Promise is created. That means server.send(...).catch(...) right after construction cannot catch the failure and instead gets a synchronous exception, which is inconsistent with the rest of the Promise-based methods in this module. For no-callback calls, this should return a rejected Promise so callers can reliably handle startup races.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improvement: Allow server send // client bind and listen

1 participant