I have some code that using UNIX sockets. But I need to compile it for winodws(using mingw32 on mac os x) but I don't want to use winsock because I'm worried about compatibility! Is there is a way to use UNIX sockets on windows?
If you stick to the BSD API that Winsock provides then you wont have that many problems. A small amount of start up and shutdown code will be Windows specific but most of the socket code will be cross platform.
I'd suggest looking into cygwin (http://www.cygwin.com/), they make every effort to be compatible. However, I have no idea how you would cross-compile for that environment on Mac OSX.
Related
I have a student task to read PCI info via 0xCF8 and 0xCFC ports using outl(), inl() functions. It assumes I use Linux x86, but can I do such things on macos with M1 chip?
I found <sys/uio.h> header but it does not define functions prototypes.
outl and inl are platform-specific functions for Linux. If it is an exercise, and you have to submit a code snippet, then I suggest installing some kind of virtual machine (VirtualBox or maybe Docker Desktop) and write a program for Linux, otherwise your code would be unlikely to be accepted, since it'd use completely different low-level API.
Forgive my ignorance: I need to use a library that requires a UNIX system (LIBSHORTTEXT). Do I need to install a virtual machine with Unix or is Cygwin enough? (I've read quite a few articles about the difference between them but I don't really understand the practical difference for this specific use). Thanks!
Edit: The documentation that said that the library needs UNIX is here
That really depends on what makes the library "require UNIX". Looking at it briefly, it appears to be ANSI C and Python, both of which should either compile or be fairly easy to port on a Windows development system. In your case I'd go with Cygwin if you don't already have a development suite running, as it is likely to allow you to just get things running.
A Virtual Machine is a bit more compartmentalized, so much less connection between Windows and the running software. Unless you are planning to use the operating system in the Virtual Machine as a target for your program, it is a bit of overkill in this case, IMHO.
Hope this helps.
Normally I would say Cygwin will do, but it depens on how you use the library. And when you say that the library requires a UNIX system what do you mean? Are you building a python or c++ program?
The main difference between working in cygwin and a VM is that cygwin is still working in a windows environment with windows directories and hardware drivers, whereas a VM have all this emulated as if it actually was a UNIX machine.
I'm trying to compile a C program that uses libpcap in statistical mode on OSX. The original code was written for Windows, using the winpcap library. The version of libpcap on my Mac has never heard of the pcap_setmode function that it uses - I've got a nasty feeling that it might be Windows-specific.
Is there any way to capture in stats-mode on OSX? If not, is there something about the architecture/capabilities of the OS that prevents this, or is this an extra feature added to WinPcap which has never been a feature of the main library?
pcap_setmode() only has a definition in the Win32 port, because the WinPcap driver for Windows is the only packet capture mechanism that supports statistical mode; BPF in Mac OS X and *BSD and AIX and Solaris 11 don't support it, PF_PACKET sockets in Linux don't support it, DLPI in Solaris and HP-UX don't support it, etc..
UN*Xes generally come with a mechanism that supports capturing packets, so libpcap can just use that, without adding its own kernel-mode code; this means it can't control what facilities those capture mechanisms have - if a capture mechanism doesn't have it, libpcap can't add it. Windows doesn't come with such a mechanism; it does come with NDIS, which can support such a mechanism, so WinPcap comes with a kernel-mode driver that uses NDIS to implement such a mechanism, and thus has some more control over what features it offers.
pcap_setmode() only has a definition in the Win32 port (for unknown reasons to me).
I've got an Atmel AVR A90USBxxxx device that I have configured to "talk USB" via CDC. It's designed to take input from a Host computer, running Windows, Linux, or OS X.
I'm under the impression that Linux and OS X will immediately recognize this CDC device, and with a simple .inf a Windows machine can be told my VID/PID should be opened as a CDC device using usbser.sys.
My question is once the OS has opened this USB device as a serial device, how can I programmatically read and write to that port (for each of the 3 OS's listed but most detail is needed for Windows as I'm completely unfamiliar there)
Thanks
The answer really depends on what programming language you intend to use. Without knowing what language you intend to use, I can't tell you exactly how to do it, but I can point you in the right direction.
For prototyping, I recommend using Python with the PySerial module. It's very easy to set up and quickly write a functional prototype. Python will run on Windows, Linux, and OS X. That way you only need to write the serial communication code once and you can test on all of your platforms.
The PySerial documentation contains some examples for how to read and write to the port.
If Python doesn't work for you in production, I would still recommend sticking with a programming language that has a cross-platform serial port library if possible.
Here's a question that was asked already about a cross-platform serial port library for C: C: cross-platform RS-232 serial library?
On Windows, it's possible to program an LSP service on top of Winsock which provides the ability to do a lot of manipulation/etc. with networked applications. For instance, some anti virus applications register an LSP and analyse network traffic that way. Is there a friendly way to accomplish the same sort of thing on OSX?
IPFW (same/similar to IPFW in other BSDs) is the Mac OS X firewall: http://developer.apple.com/mac/library/documentation/Darwin/Reference/ManPages/man8/ipfw.8.html
Depending on what you're after you may want to look into using divert:
http://blog.loudhush.ro/2008/06/using-divert-sockets-to-log-http.html
http://developer.apple.com/mac/library/documentation/Darwin/Reference/ManPages/man4/divert.4.html