Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6749085
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:38:52+00:00 2026-05-26T12:38:52+00:00

I wrote a wrapper class around libpcap for python3 but I’m struggling to find

  • 0

I wrote a wrapper class around libpcap for python3 but I’m struggling to find useful documentation on how to deal with ctype arrays in python.

self.packetdata = ctypes.POINTER(ctypes.c_ubyte*65536)() 
....
return  self.pkthdrPointer.contents.len,self.packetdata.contents

I am accessing it this way..

#!/usr/bin/python3.2 
from pycap import pycap
packet = pycap(interface="wlan0", count=10)
for len,data in packet:
    print(type(data))

The output is as follows:

<class 'pcap_struct.c_ubyte_Array_65536'>
<class 'pcap_struct.c_ubyte_Array_65536'>
<class 'pcap_struct.c_ubyte_Array_65536'>
<class 'pcap_struct.c_ubyte_Array_65536'>

now the array is initialized to 65536 0’s and the packet data is “len” long. I need to convert the data into a more workable format, but I can’t make it a string because packets can have null characters. Anyone have a suggestion on what (and how) datatype I should convert it to?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T12:38:53+00:00Added an answer on May 26, 2026 at 12:38 pm

    Under Python 3.x, you want the “bytes” or “bytearray” type to represent octet streams like packets. From there, you can manipulate it or convert it into a string if you need to for display. But for the native data type you would most likely want a bytearray I’m thinking.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the c++ STL heap algorithms, and I wrote a wrapper class around
I wrote a quick and dirty wrapper around svn.exe to retrieve some content and
I'm trying to write a wrapper around Image_Graph bar charts. I actually wrote the
When writing a class to act as a wrapper around a heap-allocated object, I
I wrote a small Server class which basically is a TcpListener wrapper and ThreadPool
Has someone written a simple Cocoa wrapper class around tar archiving/unarchiving of files? I
I wrote a little C++ wrapper around some parts of GSL and encounter the
I wrote a wrapper for a COM object that only excepted strings as input,
I wrote a wrapper DLL for some native c++ functions and compiled it in
I wrote a WinMM library wrapper library that exposes WaveOut and WaveIn classes for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.