brainman
unread,Apr 21, 2011, 12:23:50 AM4/21/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golan...@googlegroups.com, Russ Cox, alex.b...@gmail.com, Hector Chu
>>>
..., I think the correct solution to this is to open
the file with CreateFile with the FILE_FLAG_OVERLAPPED flag set and
then pass a real Overlapped data structure to ReadFile/WriteFile/
WaitCommEvent and then call GetOverlappedResult or WaitForSingleObject
to wait for the result of those functions. ...
<<<
Sounds like a plan. I use to do just that long time ago when talking to a serial port. You would have to employ Windows event in Overlapped structure, then you could wait for data to arrive.
>>>
Option 4 is ???
<<<
You could start from scratch, like net package. It is not trivial, but if you know what you're doing, it shouldn't be too much code.
>>>
Reading through the sources, I'm not sure how syscall.Pread works on
windows with a file that was opened with os.Open because seems to me
like it would need to be opened with FILE_FLAG_OVERLAPPED for the
Overlapped data structure used in syscall.Pread to be effective.
<<<
Not true. We use Overlapped to specify file offset. There is no really "overlapped" io there. If you look at the manual, it is there.
>>>
I've been looking through the windows syscall files and find the
approach very interesting. Eventually, I would like to use
syscall.LoadLibrary instead of cgo for WaitCommEvent/SetCommState/
SetCommTimeouts. The advantage to me of using syscall instead of cgo
is that I can cross compile for windows without having to boot into
windows. It's still a bit scary to lose the type checking though.
<<<
It's quite easy to generate any system Windows calls. Just look at src/pkg/exp/wingui (see how zwinapi.go is generated). You could easily build all your required function calls. I don't understand your last statement about "type checking".
Alex