Page 1
Page 2
Page 3
I was so excited (sad really!) when I loaded
by eVB CD, and discovered that eVB contained a Winsock control.
No longer was my PC software, GUI3000 destined to be lonely, I
could develop a 'little brother' for it, GUI3000 for Pocket PC.
So Off I went, coding in eVB to talk to my existing server. I
connected, received data, and ....... nothing. The application
stopped responding. Off to the knowledge base. Search on eVB and
Winsock.
Q234576
- BUG: Winsock Control Might Not Receive Binary Data
Not a problem, I thought, search the newsgroups.
Discover that lots of other people appear to have problems using
the Winsock control, due to its apparent lack of ability to deal
with binary data.
Next step - panic. How can I deal with this?
Second step - wonder why Microsoft use the
word 'might',rather than the more appropriate 'will'.
Third step (the difficult one), sit and think
my way around the problem.
The following code is part of my thought process.
It is for a very simple Telnet Terminal Emulator, built using
the Winsock control. It may not be the most efficient way to handle
binary data, but if anyone has any better ideas, I would be glad
to hear them.
The key to handling binary data is to get the Winsock
control to return a byte array, and then translate it.
There is only one form in the project, and
it is pretty simple.
You will need to add a Winsock control to
the project.
Add to the form a Winsock control, and call
it WinSockTerm. Add a couple of buttons, cmdConnect
and cmdDisconnect (enabled = false), a couple of labels,
and a couple more text boxes, txtIp and txtport.
Give txtport an initial value of 23, the default telnet
port. The finished result should look like this:

Declare some variables for use within the
form.
LoadCursor and Setcursor are only used to
display the 'hourglass' when we are connecting.
Declare Function LoadCursor Lib "coredll.dll"
_
Alias "LoadCursorW" _
(ByVal hInstance As Long, _
ByVal lpCursorName As Long) As Long
Declare Function SetCursor Lib "coredll.dll" _
(ByVal hCursor As Long) As Long
Private idata As String
Private ict As Integer
Private Last_Key As String
Private bData() As Byte
Private Logged_On As Boolean
Private DispBuff As String
Private Printf As String
Private sdata As String
Private Rdata As String
Private WkData As String
Private Esc_Sequence As String
When you click on 'Connect', the winsockterm.remotehost
should be set to the ip address in the txtIp box, and the winsockterm.remote
port should be set to the value of txtPort. Then call the Winsockterm.connect
method.
Next Page