Click here to Skip to main content
15,903,362 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Cannot Run the Database on other PC Pin
siew hoon27-Feb-04 16:31
siew hoon27-Feb-04 16:31 
GeneralRe: Cannot Run the Database on other PC Pin
David Crow1-Mar-04 2:26
David Crow1-Mar-04 2:26 
GeneralRe: Cannot Run the Database on other PC Pin
siew hoon1-Mar-04 4:06
siew hoon1-Mar-04 4:06 
GeneralMicrosoft Office Chart 9.0 Pin
krugger21-Feb-04 13:11
krugger21-Feb-04 13:11 
GeneralEnumWindows() Pin
Nirav Doshi21-Feb-04 12:17
Nirav Doshi21-Feb-04 12:17 
GeneralRe: EnumWindows() Pin
Gary R. Wheeler21-Feb-04 12:36
Gary R. Wheeler21-Feb-04 12:36 
GeneralRe: EnumWindows() Pin
Nirav Doshi21-Feb-04 12:41
Nirav Doshi21-Feb-04 12:41 
Generalconsole i/o problems Pin
#937021-Feb-04 12:04
#937021-Feb-04 12:04 
Hello,

I am trying to make a little Windows console telnet program but I have the following problem and I have no more idea. Every time when the user presses a key, the input is sent to the remote host. The receiving data is printed to the console screen. Mostly when the user presses ENTER, the input is sent and also received but it is _not_ printed to the screen. The ENTER is printed when a second ENTER or any other key is pressed, or when another application is activated. Can anybody tell me why the ENTER is not printed immediately?
Please also tell me the "dont's" of my little function because I began programming a few months ago.

Thank you,

/ms

void Verbinder::manuellI()
{
DWORD anzahl = 0; // number of INPUT Records
DWORD consoleMode; // saved console mode before changing it
DWORD geschrieben; // number of written chars
DWORD recRead = 0; // number of written events read with ReadConsoleInput
HANDLE msConsole; // Input Handle for the console Console Fenster
HANDLE msConsoleO; // Output Handle for the Console Fenster
bool ende = false; // true when ALT+N is pressed
char zuSenden; // key which should be sent to remote host

msConsole = GetStdHandle(STD_INPUT_HANDLE);
msConsoleO = GetStdHandle(STD_OUTPUT_HANDLE);

if (!GetConsoleMode(msConsole, &consoleMode))
{
//error
}

if (!SetConsoleMode(msConsole, NULL))
{
//error
}

// deactivate Nagle:
/*int nagleOff = 1;
if (setsockopt(verbindungsSock, IPPROTO_TCP, TCP_NODELAY, (char *) &nagleOff, sizeof(nagleOff) == -1) == SOCKETERROR)
{
//error
}*/

unsigned long dataToRead = 0;
while (!ende)
{
GetNumberOfConsoleInputEvents(msConsole, &anzahl);
INPUT_RECORD *inBuf = new INPUT_RECORD[anzahl];
ReadConsoleInput(msConsole, inBuf, anzahl, &recRead);

for (DWORD i = 0; i < recRead; i++)
{
int bytes = 0;
if (ioctlsocket(verbindungsSock, FIONREAD, &dataToRead))
{
bla.fehlerAusgabe("ioctlsocket Fehler! Manueller Modus nicht moeglich!");
ende = true;
break;
}

while (dataToRead)
{
bytes = recv(verbindungsSock, buf, BUFFER_SIZE - 1, 0);
if (WSAGetLastError())
{
bla.fehlerAusgabe("Kein Socket fuer die Verbindung!");
ende = true;
i = recRead;
break;
}
buf[bytes] = 0x00;
WriteConsole(msConsoleO, buf, bytes, &geschrieben, NULL);
if (dataToRead >= 1024)
{
dataToRead -= 1024;
}
else
dataToRead = 0;
}

switch (inBuf[i].EventType)
{
case KEY_EVENT:
switch (inBuf[i].Event.KeyEvent.dwControlKeyState)
{
case LEFT_ALT_PRESSED:
case RIGHT_ALT_PRESSED:
{
// process ALT
break;
}
default:
break;
}

if (inBuf[i].Event.KeyEvent.bKeyDown && inBuf[i].Event.KeyEvent.uChar.AsciiChar)
{
zuSenden = inBuf[i].Event.KeyEvent.uChar.AsciiChar;
uint sentBytes = send(verbindungsSock, &zuSenden, 1, 0);
if (sentBytes != 1)
{
//error
}
break;
}
default:
break;
}
}
delete[] inBuf;
inBuf = 0;

}
if (!SetConsoleMode(msConsole, consoleMode))
{
//error
}
}
GeneralRe: console i/o problems Pin
valikac21-Feb-04 14:36
valikac21-Feb-04 14:36 
GeneralRe: console i/o problems Pin
#937022-Feb-04 1:56
#937022-Feb-04 1:56 
GeneralSomeone, Anyone Help Plz Pin
MrNiceBerG21-Feb-04 11:34
MrNiceBerG21-Feb-04 11:34 
GeneralRe: Someone, Anyone Help Plz Pin
Gary R. Wheeler21-Feb-04 12:09
Gary R. Wheeler21-Feb-04 12:09 
GeneralRe: Someone, Anyone Help Plz Pin
Ravi Bhavnani21-Feb-04 12:32
professionalRavi Bhavnani21-Feb-04 12:32 
GeneralRe: Someone, Anyone Help Plz Pin
Gary R. Wheeler21-Feb-04 13:05
Gary R. Wheeler21-Feb-04 13:05 
GeneralNeed help with restaring a thread Pin
Aralguppe21-Feb-04 8:23
Aralguppe21-Feb-04 8:23 
GeneralRe: Need help with restaring a thread Pin
Neville Franks21-Feb-04 9:50
Neville Franks21-Feb-04 9:50 
GeneralRe: Need help with restaring a thread Pin
Tim Smith21-Feb-04 12:10
Tim Smith21-Feb-04 12:10 
GeneralRe: Need help with restaring a thread Pin
Neville Franks21-Feb-04 20:01
Neville Franks21-Feb-04 20:01 
GeneralRe: Need help with restaring a thread Pin
Aralguppe22-Feb-04 7:09
Aralguppe22-Feb-04 7:09 
GeneralRe: Need help with restaring a thread Pin
Neville Franks22-Feb-04 9:24
Neville Franks22-Feb-04 9:24 
GeneralRe: Need help with restaring a thread Pin
Gary R. Wheeler21-Feb-04 12:21
Gary R. Wheeler21-Feb-04 12:21 
GeneralRe: Need help with restaring a thread Pin
Aralguppe22-Feb-04 6:40
Aralguppe22-Feb-04 6:40 
GeneralRe: Need help with restaring a thread Pin
Gary R. Wheeler22-Feb-04 15:43
Gary R. Wheeler22-Feb-04 15:43 
Generalrotate function Pin
Cuu21-Feb-04 7:55
Cuu21-Feb-04 7:55 
GeneralRe: rotate function Pin
alex.barylski21-Feb-04 11:16
alex.barylski21-Feb-04 11:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.