Hello Guys
I have been given the source code to a little program that i would like to implement into a .adp project. It is a little program that connects to another program on a server: sends and recieves som information. The code is writtin is MS Visual Studio.
I'm very much a beginner but i try the best i can
The original code:
Now this is what i have come up with so far:
This is how far i've gotten.
Can anybody help me correct it and maybe get the rest ?
Any help is wonderful.
I have been given the source code to a little program that i would like to implement into a .adp project. It is a little program that connects to another program on a server: sends and recieves som information. The code is writtin is MS Visual Studio.
I'm very much a beginner but i try the best i can

The original code:
Code:
Function Connect(ByVal server As [String], ByVal port As Int32, ByVal message As [String]) As Boolean
Try
' Create a TcpClient.
' Note, for this client to work you need to have a TcpServer
' connected to the same address as specified by the server, port
' combination.
Dim oWatch As New Stopwatch
oWatch.Reset()
oWatch.Start()
Dim client As New TcpClient(server, port)
client.ReceiveTimeout = 10000
' Translate the passed message into ASCII and store it as a Byte array.
'Dim sendData As [Byte]() = System.Text.Encoding.UTF7.GetBytes(message)
Dim sendData As [Byte]() = System.Text.Encoding.GetEncoding("iso-8859-1").GetBytes(message)
' Buffer for reading data
Dim bytes(1024) As Byte
' String to store the response ASCII representation.
Dim responseData As [String] = [String].Empty
' Get a client stream for reading and writing.
' Stream stream = client.GetStream();
Dim stream As NetworkStream = client.GetStream()
' Send the message to the connected TcpServer.
stream.Write(sendData, 0, sendData.Length)
' Receive the TcpServer.response.
' Buffer to store the response bytes.
'data = New [Byte](256) {}
' Read the first batch of the TcpServer response bytes.
Dim i As Int32
i = stream.Read(bytes, 0, bytes.Length)
While (i <> 0)
responseData = System.Text.Encoding.GetEncoding("iso-8859- 1").GetString(bytes, 0, i)
tbSvarText.Text = tbSvarText.Text & responseData
Console.WriteLine("Received: {0}", responseData)
i = stream.Read(bytes, 0, bytes.Length)
End While
' Close everything.
stream.Close()
client.Close()
Code:
' Create a TcpClient.
' Note, for this client to work you need to have a TcpServer
' connected to the same address as specified by the server, port
' combination.
Private WithEvents Winsock1 As Winsock
Sub Init()
Set Winsock1 = CreateObject("MSWinsock.Winsock")
Winsock1.RemoteHost = "Localhost"
Winsock1.RemotePort = "701"
Winsock1.Connect
' Translate the passed message into ASCII and store it as a Byte array.
Dim sendIndhold() As Byte
Dim i As Integer
sendIndhold = StrConv(message, vbFromUnicode)
For i = 0 To UBound(message)
Next
' Buffer for reading data
Dim bytes(1024) As Byte
' String to store the response ASCII representation.
Dim responseData As String
responseData = Empty
' Get a client stream for reading and writing.
Dim modtaget As Winsock
modtaget = Winsock.GetData 'Really in doubt here.. Networkstreamer?
' Send the message to the connected TcpServer.
Winsock1.sendData (sendIndhold)
' Receive the TcpServer.response.
' Read the first batch of the TcpServer response bytes.
Dim k As Double
Winsock1.GetData (bytes)
responseData =
Can anybody help me correct it and maybe get the rest ?
Any help is wonderful.

Last edited by a moderator: