www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - reading and writing from a socket simo at once

reply "Ameer Armaly" <ameer_armaly hotmail.com> writes:
Hi.
How would I be able to read from a socket, but still take in info from the 
keyboard and send it out;kind of like telnet?

-- 
---
Life is either tragedy or comedy.
 Usually it's your choice. You can whine or you can laugh.
--Animorphs 
Jul 06 2005
next sibling parent "Regan Heath" <regan netwin.co.nz> writes:
On Wed, 6 Jul 2005 17:31:56 -0400, Ameer Armaly <ameer_armaly hotmail.com>  
wrote:
 How would I be able to read from a socket, but still take in info from  
 the keyboard and send it out;kind of like telnet?
Start a thread, in that thread read data from the socket into a buffer. The main thread then loops checking for data in the buffer and checking for keystrokes. You need a non blocking keystroke checking function, some functions block until a complete line has been entered. You'll need to synchronise access to the socket and the buffer, probably best to place both of these in a class dedicated to this purpose. Regan
Jul 06 2005
prev sibling parent "Regan Heath" <regan netwin.co.nz> writes:
On Wed, 6 Jul 2005 17:31:56 -0400, Ameer Armaly <ameer_armaly hotmail.com>  
wrote:
 How would I be able to read from a socket, but still take in info from  
 the keyboard and send it out;kind of like telnet?
Here is an example telnet program I just wrote in D. I don't guarantee it works at all, especially on anything other than windows, or for the most basic things. Regan
Jul 07 2005