1) If you use Visual C++ and don't mind using MFC, the CSocket class will probably give you the functionality you want.
2) By Using TCP/IP and setting up a dialup connection, your program will work over any medium. How the IP number is assigned is another matter though.
3) If you just want to play with serial IO, or anything else through the win32 api, you want some kind of reference to the win32 api itself.
check on the following functions to get a 32 bit handle that identifies the device:
BOOL SetCommConfig() // can be used to set the baud rate
You can find the type of device assigned to a handle with
GetFileType(handle)
When done, you must close it with CloseHandle()
Most devices under win32 are opened using the CreateFile function.
HANDLE CreateFile("COM?", desiredAccess, shareMode, SecurityAttributes...)
That's it, unless you want to use threads. If you're starting, I don't advise it.
I think Option 2 is your best for Windows. Even if you don't get anything working, the knowledge will be of use. MSDN is an effective reference for MFC.
4)If you're running Windows but want knowledge that applies to other platforms, install cygwin and use Berkley sockets over TCP/IP.
|