Skip to content

Instantly share code, notes, and snippets.

@hellojukay
Created August 14, 2021 04:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hellojukay/fc9eaebb1cef9bb6f6effb1ad950506d to your computer and use it in GitHub Desktop.
Save hellojukay/fc9eaebb1cef9bb6f6effb1ad950506d to your computer and use it in GitHub Desktop.
let () =
let sock = Unix.socket Unix.PF_INET Unix.SOCK_STREAM 0 in
let address = Unix.inet_addr_of_string "127.0.0.1" in
let socket_address = Unix.ADDR_INET (address, 22) in
Unix.connect sock socket_address;
let buffer = Bytes.create 1024 in
let len = Unix.read sock buffer 0 (Bytes.length buffer) in
Printf.printf "%d %s" len (Bytes.to_string buffer)
@hellojukay
Copy link
Author

vagrant@archlinux tcp $ dune exec ./tcp.exe
21 SSH-2.0-OpenSSH_8.6

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