Article View: comp.os.os2.programmer
Article #149Re: Data communications and OS2 threads
From: David Charlap
Date: Tue, 03 Nov 1992 21:31
Date: Tue, 03 Nov 1992 21:31
29 lines
2260 bytes
2260 bytes
In article <julian.720779089@sun-1> julian@sun-1.cs.uct.ac.za (Julian Hansen) writes: >I am totally ignorant about anything OS2 but I am writing a programme that >will run under the OS2 environment. The programme is an on line dial up >information programme which uses the telephone network. The programme >manageing the whole thing creates a new 'thread' each time a call comes in >and runs my code for each call. What I need to know is has anyone out there >any tips for me - I really need some input on how OS2 passes the characters >comming in via the telephone line to the different versions of my code i.e. >what function do I envoke to a) check if a character is sitting in the >communication buffer and b) if there is a character how do I get it out of >the buffer. Use DosRead. This function will return characters in the buffer. If there are no characters, it will block, returning when it's ready. I believe you can also do an unbuffered read, in which case it will return with an error condition when there are no characters. If this isn't good enough, you can simulate asychronous reading using threads: Create a thread which continuously read the port and shoves data into a global buffer. This thread can use the blocking read, so it won't take up any processor time when no data is coming in. Your program can then check for the presence of data in the buffer, since it is a global memory structure. -- David Charlap |"there aren't 50,000 things for which it's worth writing dic5340@hertz.njit.edu| software; and the computer industry doesn't have enough ----------------------+ programmers to create that much good software. Therefore, most of it must be worthless" -- Boris Beizer "The Frozen Keyboard"
Technical Details
Message-ID:
<1992Nov3.213114.9468@njitgw.njit.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!walter!bellcore!rutgers!njitgw.njit.edu!hertz.njit.edu!dic5340References:
<julian.720779089@sun-1>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!walter!bellcore!rutgers!njitgw.njit.edu!hertz.njit.edu!dic5340 From: dic5340@hertz.njit.edu (David Charlap) Newsgroups: comp.os.os2.programmer Subject: Re: Data communications and OS2 threads Keywords: Data comm. Message-ID: <1992Nov3.213114.9468@njitgw.njit.edu> Date: 3 Nov 92 21:31:14 GMT References: <julian.720779089@sun-1> Sender: news@njit.edu Organization: New Jersey Institute of Technology, Newark, N.J. Lines: 29 Nntp-Posting-Host: hertz.njit.edu