{"id":16981351,"url":"https://github.com/charonn0/rb-pcap","last_synced_at":"2025-07-18T10:07:06.843Z","repository":{"id":145923024,"uuid":"59438787","full_name":"charonn0/RB-PCAP","owner":"charonn0","description":"A Realbasic and Xojo binding to libpcap\u0026WinPcap/Npcap","archived":false,"fork":false,"pushed_at":"2024-07-07T22:46:45.000Z","size":223,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-21T23:31:22.779Z","etag":null,"topics":["libpcap","npcap","packet-capture","packet-sniffer","pcap","realbasic","winpcap","xojo"],"latest_commit_sha":null,"homepage":"","language":"REALbasic","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/charonn0.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"license.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"charonn0"}},"created_at":"2016-05-22T23:16:11.000Z","updated_at":"2024-07-07T22:46:49.000Z","dependencies_parsed_at":null,"dependency_job_id":"6c2f1bcd-ad51-4b32-9737-2a826b5d8538","html_url":"https://github.com/charonn0/RB-PCAP","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/charonn0/RB-PCAP","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charonn0%2FRB-PCAP","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charonn0%2FRB-PCAP/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charonn0%2FRB-PCAP/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charonn0%2FRB-PCAP/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/charonn0","download_url":"https://codeload.github.com/charonn0/RB-PCAP/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charonn0%2FRB-PCAP/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265738459,"owners_count":23820162,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["libpcap","npcap","packet-capture","packet-sniffer","pcap","realbasic","winpcap","xojo"],"created_at":"2024-10-14T02:05:15.297Z","updated_at":"2025-07-18T10:07:06.809Z","avatar_url":"https://github.com/charonn0.png","language":"REALbasic","funding_links":["https://github.com/sponsors/charonn0"],"categories":[],"sub_categories":[],"readme":"# Introduction\n[libpcap](http://www.tcpdump.org/)/[WinPcap](https://www.winpcap.org/) is the user-mode interface to a kernel-mode network packet capture driver for Linux, OS X and Windows operating systems. \n\n**RB-PCAP** is a libpcap/winpcap [binding](http://en.wikipedia.org/wiki/Language_binding) for Realbasic and Xojo (\"classic\" framework) projects. \n\n![RB-PCAP demo on Windows](http://i.imgur.com/pdbKqtK.png)\n\n_This screen shot depicts the RB-PCAP demo running under Windows 7._\n\n## Become a sponsor\nIf you use this code in a commercial project, or just want to show your appreciation, please consider sponsoring me through GitHub. https://github.com/sponsors/charonn0\n\n## Synopsis\nThis project supplies several object classes for dealing with different aspects of the libpcap/WinPcap api.\n\n|Object Class|Comment|\n|------------|-------|\n|[`Adaptor`](https://github.com/charonn0/RB-PCAP/wiki/PCAP.Adaptor)|A local network adaptor that can be opened for packet capture.| \n|[`Capture`](https://github.com/charonn0/RB-PCAP/wiki/PCAP.Capture)|A packet capture operation. Either \"online\" (from a network adaptor) or \"offline\" (from a PCAP file.)|\n|[`DumpFile`](https://github.com/charonn0/RB-PCAP/wiki/PCAP.DumpFile)|A standard PCAP file to write packets to.|\n|[`Filter`](https://github.com/charonn0/RB-PCAP/wiki/PCAP.Filter)|A Berkeley Packet Filter (BPF) program that is compiled from a high-level filtering expression.|\n|[`Packet`](https://github.com/charonn0/RB-PCAP/wiki/PCAP.Packet)|A single Internet packet, as captured from an `Adaptor` or PCAP file.|\n\nUse [PCAP.GetCaptureDevice](https://github.com/charonn0/RB-PCAP/wiki/PCAP.GetCaptureDevice) to get an instance of `Adaptor` for the local interface you want to capture from. Then, pass the `Adaptor` to [PCAP.BeginCapture](https://github.com/charonn0/RB-PCAP/wiki/PCAP.BeginCapture) to start capturing packets. You may also read from a standard PCAP file by passing the file as a FolderItem to [PCAP.OpenCapture](https://github.com/charonn0/RB-PCAP/wiki/PCAP.OpenCapture).\n\n## Example\nThis example captures 64KB of filtered packets from a local network adaptor and saves them to a standard PCAP file on the user's desktop.\n\n```realbasic\n  ' get the first available device\n  Dim iface As PCAP.Adaptor = PCAP.GetCaptureDevice(0)\n  ' open the device\n  Dim capture As PCAP.Capture = PCAP.BeginCapture(iface)\n  ' create a file to write packets to\n  Dim dumpfile As PCAP.DumpFile = PCAP.DumpFile.Create(capture, SpecialFolder.Desktop.Child(\"test.pcap\"))\n  \n  ' create a filter program\n  Dim expression As String = \"host example.com and port 80 and tcp\"\n  Dim filter As PCAP.Filter = PCAP.Filter.Compile(expression, capture)\n  \n  If filter \u003c\u003e Nil Then\n    ' assign the filter to the capture\n    capture.CurrentFilter = filter\n    ' begin reading packets from the capture buffer\n    Do Until capture.EOF Or dumpfile.Position \u003e 1024 * 64\n      'wait for next packet or timeout\n      Dim p As PCAP.Packet = capture.ReadNext()\n      If p \u003c\u003e Nil Then\n        ' a packet was received before timeout\n        ' write it to the file\n        dumpfile.WritePacket(p)\n      End If\n    Loop\n    \n  Else\n    ' invalid expression\n    MsgBox(PCAP.Filter.LastCompileError)\n  End If\n  \n  dumpfile.Close\n  capture.Close\n```\n\n## How to incorporate RB-PCAP into your Realbasic/Xojo project\n### Import the PCAP module\n1. Download the RB-PCAP project either in [ZIP archive format](https://github.com/charonn0/RB-PCAP/archive/master.zip) or by cloning the repository with your git client.\n2. Open the RB-PCAP project in REALstudio or Xojo. Open your project in a separate window.\n3. Copy the PCAP module into your project and save.\n\n**Caution**: When running PCAP code in the Xojo debugger you must take care to allow the application to terminate normally, even if an exception is raised. Termination from the debugger prevents Destructor methods from running which can leave the PCAP driver in an inconsistent state!\n\n### Ensure the PCAP driver is installed\nPCAP is not installed by default on most systems, and will need to be installed separately. On Windows you can use either WinPcap (older, unmaintained) or Npcap (newer, actively maintained.) Npcap will be used if it is available and if the `PCAP.USE_NPCAP` constant is set to `True`.\n\n* [WinPCAP download](https://www.winpcap.org/install/default.htm) (Windows)\n* [Npcap download](https://nmap.org/npcap/) (Windows Vista and newer)\n* [libpcap download](http://www.tcpdump.org/#latest-releases) (Linux/OS X)\n\nRB-PCAP will raise a PlatformNotSupportedException when used if all required DLLs/SOs/DyLibs are not available at runtime. \n\nAdditionally, on most Unix-like systems you must run the app with root privileges in order to capture packets from a local adaptor.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcharonn0%2Frb-pcap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcharonn0%2Frb-pcap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcharonn0%2Frb-pcap/lists"}