Imports System.Net.Sockets
Imports System.Text
Public Class Form1
Dim TcpClient As New System.Net.Sockets.TcpClient()
Dim NetStream As NetworkStream
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim serverStream As NetworkStream = TcpClient.GetStream()
Dim sendBytes As [Byte]() = Encoding.UTF8.GetBytes("$")
System.Text.Encoding.ASCII.GetBytes("$")
NetStream.Write(sendBytes, 0, sendBytes.Length)
NetStream.Flush()
Dim bytes(64) As Byte
NetStream.Read(bytes, 0, CInt(TcpClient.ReceiveBufferSize))
Dim returndata As String = Encoding.ASCII.GetString(bytes)
System.Text.Encoding.ASCII.GetString(bytes)
msg("Data from Server : ")
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
msg("server2")
TcpClient.Connect("autoit.smf4u.com", 80)
Label1.Text = "Client Socket Program - Server Connected ..."
End Sub
Sub msg(ByVal mesg As String)
RichTextBox1.Text = RichTextBox1.Text + Environment.NewLine + " >> " + mesg
End Sub
End Class