|
-
Feb 7th, 2000, 04:47 PM
#1
Thread Starter
New Member
I try to make a program in Visual Basic that executes it when I make a session telnet through SLNet server telnet version 2.5. in win NT.
Now we work in C, and we get the environment of slnet with getenv API, we write to slnet pipe with write API (over the handle of open API) and wait response with readconsoleinput API (over the handle of GetStdHandle(STD_INPUT).
Can I do this with Winsock control?
From Visual Basic, I have had success in connect with the pipe of the server telnet, and with writefile API.
But I still have'nt got to read from the pipe.
I don't know why I can't read from a telnet session and the readfile API don't go.
This is the code that I have made. It`s more easy but the final part (readfile) doesn't go.
///////////////////////////////////////////
name = "//./pipe/" + Environ("PIPENAME")
m_hPipe = CreateFile(name, GENERIC_READ + GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0)
txtdata = "Hello world" + Chr(10) + Chr(13) + ">"
For i = 1 To Len(txtdata)
Data(i - 1) = Asc(Mid(txtdata, i, 1))
Next i
bRet = WriteFile(m_hPipe, Data(0), Len(txtdata), BytesWritten, 0)
'until here ok
outstr = ""
Do
Sleep (1000)
lRet = ReadFile(m_hPipe, Buffer(0), 1, BytesRead, 0)
For i = 1 To BytesRead
outstr = outstr & (Chr(Buffer(i - 1)))
If Buffer(i-1)=13 Or Buffer(i-1)=10 Then
GoTo fuera
End If
Next i
Loop Until True
fuera:
txtdata = "ok" + Chr(10) + Chr(13)
For i = 1 To Len(txtdata)
Data(i - 1) = Asc(Mid(txtdata, i, 1))
Next i
bRet = WriteFile(m_hPipe, Data(0), Len(txtdata), BytesWritten, 0)
Sleep (3000)
If m_hPipe <> 0 Then CloseHandle m_hPipe
//////////////////////////////////////////
Best Regard
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|