Skip to content

Week2/m4 tcp handshake - #21

Merged
aman-a-shah merged 11 commits into
mainfrom
week2/m4-tcp-handshake
Sep 11, 2026
Merged

Week2/m4 tcp handshake#21
aman-a-shah merged 11 commits into
mainfrom
week2/m4-tcp-handshake

Conversation

@Shuhan6017

Copy link
Copy Markdown
Collaborator

Summary

Real TCP handshake for module 4 (Week 2, closes #13).

  • send_line/receive_line module-level helpers, with a per-connection
    leftover buffer so partial reads (a line split across two recv()s) and
    batched reads (two lines in one recv()) both work.
  • RemoteServer: binds and listens in __init__ so self.port is readable
    immediately (needed for tests on an OS-assigned port), serve_forever()
    loops on accept() and never lets a bad client crash it, and the handler
    does AUTH <token>OK/ERR bad auth, then REF <branch> → the hash
    read straight off .minigit/refs/heads/<branch> (or - if it doesn't
    exist).
  • push/pull now open a real socket, run the same handshake, and print
    the remote hash. All connection failures (refused, dropped, bad auth) are
    mapped to NetworkProtocolError — nothing else leaks out.
  • New minigit serve --port <n> --token <t> CLI command.
  • Object transfer (WANT/OBJ) is still stubbed for Week 6, per the issue.

Validation

  • [X ] scripts/quality-check.sh
  • [ X] Manual testing, if applicable:

Checklist

  • [ X] The change is focused and easy to review.
  • [ X] Tests were added or updated for behavior changes.
  • [ X] Documentation was updated for user-facing or setup changes.
  • [ X] No secrets, generated artifacts, or local-only files are included.

Notes for Reviewers

I have been a bit late on schedule lately, so this project's code was done by AI. I was able to check and confirm the generated code before commiting. There are some I'm not entirely sure, but I'd still like to push & merge it now. I'll validate it soon, but as for now, since no one is using module 4 and a merge is necessary. ill pr now.

@aman-a-shah
aman-a-shah merged commit b3369d4 into main Sep 11, 2026
1 check passed
@aman-a-shah
aman-a-shah deleted the week2/m4-tcp-handshake branch September 11, 2026 14:54
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.

Week 2 - M4: TCP handshake + RemoteServer

2 participants