<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://www.vbex.ru/index.php?action=history&amp;feed=atom&amp;title=VB.Net_Tutorial%2FSocket_Network%2FSocket_Client</id>
		<title>VB.Net Tutorial/Socket Network/Socket Client - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://www.vbex.ru/index.php?action=history&amp;feed=atom&amp;title=VB.Net_Tutorial%2FSocket_Network%2FSocket_Client"/>
		<link rel="alternate" type="text/html" href="http://www.vbex.ru/index.php?title=VB.Net_Tutorial/Socket_Network/Socket_Client&amp;action=history"/>
		<updated>2026-04-05T23:13:42Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://www.vbex.ru/index.php?title=VB.Net_Tutorial/Socket_Network/Socket_Client&amp;diff=3530&amp;oldid=prev</id>
		<title> в 16:40, 26 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://www.vbex.ru/index.php?title=VB.Net_Tutorial/Socket_Network/Socket_Client&amp;diff=3530&amp;oldid=prev"/>
				<updated>2010-05-26T16:40:30Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 16:40, 26 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://www.vbex.ru/index.php?title=VB.Net_Tutorial/Socket_Network/Socket_Client&amp;diff=3531&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://www.vbex.ru/index.php?title=VB.Net_Tutorial/Socket_Network/Socket_Client&amp;diff=3531&amp;oldid=prev"/>
				<updated>2010-05-26T12:55:54Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Using Async Socket Client==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;vbnet&amp;quot;&amp;gt;Imports System.Net.Sockets&lt;br /&gt;
Imports System.Net&lt;br /&gt;
Imports System.Threading&lt;br /&gt;
Imports System.Text&lt;br /&gt;
Imports System.Windows.Forms&lt;br /&gt;
public class UsingAsyncSocketClient&lt;br /&gt;
   public Shared Sub Main&lt;br /&gt;
        Application.Run(New Form1)&lt;br /&gt;
   End Sub&lt;br /&gt;
End class&lt;br /&gt;
Public Class Form1&lt;br /&gt;
    Inherits System.Windows.Forms.Form&lt;br /&gt;
    Public Sub New()&lt;br /&gt;
        MyBase.New()&lt;br /&gt;
        InitializeComponent()&lt;br /&gt;
    End Sub&lt;br /&gt;
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)&lt;br /&gt;
        If disposing Then&lt;br /&gt;
            If Not (components Is Nothing) Then&lt;br /&gt;
                components.Dispose()&lt;br /&gt;
            End If&lt;br /&gt;
        End If&lt;br /&gt;
        MyBase.Dispose(disposing)&lt;br /&gt;
    End Sub&lt;br /&gt;
    Private components As System.ruponentModel.IContainer&lt;br /&gt;
    Friend WithEvents btnListener As System.Windows.Forms.Button&lt;br /&gt;
    Friend WithEvents lblConnection As System.Windows.Forms.Label&lt;br /&gt;
    Friend WithEvents lblPort As System.Windows.Forms.Label&lt;br /&gt;
    Friend WithEvents txtPort As System.Windows.Forms.TextBox&lt;br /&gt;
    Friend WithEvents btnClose As System.Windows.Forms.Button&lt;br /&gt;
    Friend WithEvents btnReceive As System.Windows.Forms.Button&lt;br /&gt;
    Friend WithEvents txtMessage As System.Windows.Forms.TextBox&lt;br /&gt;
    Friend WithEvents Label1 As System.Windows.Forms.Label&lt;br /&gt;
    Friend WithEvents btnSend As System.Windows.Forms.Button&lt;br /&gt;
    Friend WithEvents Label2 As System.Windows.Forms.Label&lt;br /&gt;
    Friend WithEvents txtAddress As System.Windows.Forms.TextBox&lt;br /&gt;
    Friend WithEvents txtSend As System.Windows.Forms.TextBox&lt;br /&gt;
    &amp;lt;System.Diagnostics.DebuggerStepThrough()&amp;gt; Private Sub InitializeComponent()&lt;br /&gt;
        Me.btnListener = New System.Windows.Forms.Button()&lt;br /&gt;
        Me.lblConnection = New System.Windows.Forms.Label()&lt;br /&gt;
        Me.lblPort = New System.Windows.Forms.Label()&lt;br /&gt;
        Me.txtPort = New System.Windows.Forms.TextBox()&lt;br /&gt;
        Me.btnClose = New System.Windows.Forms.Button()&lt;br /&gt;
        Me.btnReceive = New System.Windows.Forms.Button()&lt;br /&gt;
        Me.txtMessage = New System.Windows.Forms.TextBox()&lt;br /&gt;
        Me.txtSend = New System.Windows.Forms.TextBox()&lt;br /&gt;
        Me.Label1 = New System.Windows.Forms.Label()&lt;br /&gt;
        Me.btnSend = New System.Windows.Forms.Button()&lt;br /&gt;
        Me.txtAddress = New System.Windows.Forms.TextBox()&lt;br /&gt;
        Me.Label2 = New System.Windows.Forms.Label()&lt;br /&gt;
        Me.SuspendLayout()&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        &amp;quot;btnListener&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        Me.btnListener.Font = New System.Drawing.Font(&amp;quot;Microsoft Sans Serif&amp;quot;, 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(136, Byte))&lt;br /&gt;
        Me.btnListener.Location = New System.Drawing.Point(338, 48)&lt;br /&gt;
        Me.btnListener.Name = &amp;quot;btnListener&amp;quot;&lt;br /&gt;
        Me.btnListener.Size = New System.Drawing.Size(113, 32)&lt;br /&gt;
        Me.btnListener.TabIndex = 0&lt;br /&gt;
        Me.btnListener.Text = &amp;quot;Connect&amp;quot;&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        &amp;quot;lblConnection&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        Me.lblConnection.Font = New System.Drawing.Font(&amp;quot;Microsoft Sans Serif&amp;quot;, 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(136, Byte))&lt;br /&gt;
        Me.lblConnection.Location = New System.Drawing.Point(41, 96)&lt;br /&gt;
        Me.lblConnection.Name = &amp;quot;lblConnection&amp;quot;&lt;br /&gt;
        Me.lblConnection.Size = New System.Drawing.Size(92, 24)&lt;br /&gt;
        Me.lblConnection.TabIndex = 2&lt;br /&gt;
        Me.lblConnection.Text = &amp;quot;Info&amp;quot;&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        &amp;quot;lblPort&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        Me.lblPort.Font = New System.Drawing.Font(&amp;quot;Microsoft Sans Serif&amp;quot;, 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(136, Byte))&lt;br /&gt;
        Me.lblPort.Location = New System.Drawing.Point(20, 56)&lt;br /&gt;
        Me.lblPort.Name = &amp;quot;lblPort&amp;quot;&lt;br /&gt;
        Me.lblPort.Size = New System.Drawing.Size(113, 24)&lt;br /&gt;
        Me.lblPort.TabIndex = 3&lt;br /&gt;
        Me.lblPort.Text = &amp;quot;Port&amp;quot;&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        &amp;quot;txtPort&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        Me.txtPort.Font = New System.Drawing.Font(&amp;quot;Microsoft Sans Serif&amp;quot;, 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(136, Byte))&lt;br /&gt;
        Me.txtPort.Location = New System.Drawing.Point(143, 48)&lt;br /&gt;
        Me.txtPort.Name = &amp;quot;txtPort&amp;quot;&lt;br /&gt;
        Me.txtPort.Size = New System.Drawing.Size(133, 26)&lt;br /&gt;
        Me.txtPort.TabIndex = 4&lt;br /&gt;
        Me.txtPort.Text = &amp;quot;36000&amp;quot;&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        &amp;quot;btnClose&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        Me.btnClose.Font = New System.Drawing.Font(&amp;quot;Microsoft Sans Serif&amp;quot;, 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(136, Byte))&lt;br /&gt;
        Me.btnClose.Location = New System.Drawing.Point(461, 48)&lt;br /&gt;
        Me.btnClose.Name = &amp;quot;btnClose&amp;quot;&lt;br /&gt;
        Me.btnClose.Size = New System.Drawing.Size(102, 32)&lt;br /&gt;
        Me.btnClose.TabIndex = 5&lt;br /&gt;
        Me.btnClose.Text = &amp;quot;Disconnect&amp;quot;&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        &amp;quot;btnReceive&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        Me.btnReceive.Font = New System.Drawing.Font(&amp;quot;Microsoft Sans Serif&amp;quot;, 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(136, Byte))&lt;br /&gt;
        Me.btnReceive.Location = New System.Drawing.Point(338, 272)&lt;br /&gt;
        Me.btnReceive.Name = &amp;quot;btnReceive&amp;quot;&lt;br /&gt;
        Me.btnReceive.Size = New System.Drawing.Size(113, 32)&lt;br /&gt;
        Me.btnReceive.TabIndex = 6&lt;br /&gt;
        Me.btnReceive.Text = &amp;quot;Receive&amp;quot;&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        &amp;quot;txtMessage&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        Me.txtMessage.Location = New System.Drawing.Point(143, 96)&lt;br /&gt;
        Me.txtMessage.Multiline = True&lt;br /&gt;
        Me.txtMessage.Name = &amp;quot;txtMessage&amp;quot;&lt;br /&gt;
        Me.txtMessage.ScrollBars = System.Windows.Forms.ScrollBars.Vertical&lt;br /&gt;
        Me.txtMessage.Size = New System.Drawing.Size(430, 88)&lt;br /&gt;
        Me.txtMessage.TabIndex = 7&lt;br /&gt;
        Me.txtMessage.Text = &amp;quot;&amp;quot;&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        &amp;quot;txtSend&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        Me.txtSend.Location = New System.Drawing.Point(143, 192)&lt;br /&gt;
        Me.txtSend.Multiline = True&lt;br /&gt;
        Me.txtSend.Name = &amp;quot;txtSend&amp;quot;&lt;br /&gt;
        Me.txtSend.ScrollBars = System.Windows.Forms.ScrollBars.Vertical&lt;br /&gt;
        Me.txtSend.Size = New System.Drawing.Size(430, 64)&lt;br /&gt;
        Me.txtSend.TabIndex = 9&lt;br /&gt;
        Me.txtSend.Text = &amp;quot;&amp;quot;&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        &amp;quot;Label1&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        Me.Label1.Font = New System.Drawing.Font(&amp;quot;Microsoft Sans Serif&amp;quot;, 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(136, Byte))&lt;br /&gt;
        Me.Label1.Location = New System.Drawing.Point(10, 192)&lt;br /&gt;
        Me.Label1.Name = &amp;quot;Label1&amp;quot;&lt;br /&gt;
        Me.Label1.Size = New System.Drawing.Size(144, 24)&lt;br /&gt;
        Me.Label1.TabIndex = 8&lt;br /&gt;
        Me.Label1.Text = &amp;quot;Content&amp;quot;&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        &amp;quot;btnSend&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        Me.btnSend.Font = New System.Drawing.Font(&amp;quot;Microsoft Sans Serif&amp;quot;, 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(136, Byte))&lt;br /&gt;
        Me.btnSend.Location = New System.Drawing.Point(461, 272)&lt;br /&gt;
        Me.btnSend.Name = &amp;quot;btnSend&amp;quot;&lt;br /&gt;
        Me.btnSend.Size = New System.Drawing.Size(112, 32)&lt;br /&gt;
        Me.btnSend.TabIndex = 10&lt;br /&gt;
        Me.btnSend.Text = &amp;quot;Send&amp;quot;&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        &amp;quot;txtAddress&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        Me.txtAddress.Font = New System.Drawing.Font(&amp;quot;Microsoft Sans Serif&amp;quot;, 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(136, Byte))&lt;br /&gt;
        Me.txtAddress.Location = New System.Drawing.Point(143, 16)&lt;br /&gt;
        Me.txtAddress.Name = &amp;quot;txtAddress&amp;quot;&lt;br /&gt;
        Me.txtAddress.Size = New System.Drawing.Size(420, 26)&lt;br /&gt;
        Me.txtAddress.TabIndex = 12&lt;br /&gt;
        Me.txtAddress.Text = &amp;quot;192.168.0.70&amp;quot;&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        &amp;quot;Label2&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        Me.Label2.Font = New System.Drawing.Font(&amp;quot;Microsoft Sans Serif&amp;quot;, 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(136, Byte))&lt;br /&gt;
        Me.Label2.Location = New System.Drawing.Point(20, 21)&lt;br /&gt;
        Me.Label2.Name = &amp;quot;Label2&amp;quot;&lt;br /&gt;
        Me.Label2.Size = New System.Drawing.Size(113, 24)&lt;br /&gt;
        Me.Label2.TabIndex = 11&lt;br /&gt;
        Me.Label2.Text = &amp;quot;Address&amp;quot;&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        &amp;quot;Form1&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)&lt;br /&gt;
        Me.ClientSize = New System.Drawing.Size(665, 309)&lt;br /&gt;
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.txtAddress, Me.Label2, Me.btnSend, Me.txtSend, Me.Label1, Me.txtMessage, Me.btnReceive, Me.btnClose, Me.txtPort, Me.lblPort, Me.lblConnection, Me.btnListener})&lt;br /&gt;
        Me.Name = &amp;quot;Form1&amp;quot;&lt;br /&gt;
        Me.Text = &amp;quot;Form1&amp;quot;&lt;br /&gt;
        Me.ResumeLayout(False)&lt;br /&gt;
    End Sub&lt;br /&gt;
&lt;br /&gt;
    Dim strMessage&lt;br /&gt;
    Dim myConnect As Socket&lt;br /&gt;
    Dim bteAccept(65536) As Byte&lt;br /&gt;
    Dim bteSend(65536) As Byte&lt;br /&gt;
    Private Sub btnListener_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnListener.Click&lt;br /&gt;
        Dim myThread As New Thread(New ThreadStart(AddressOf StartListen))&lt;br /&gt;
        myThread.Start()&lt;br /&gt;
    End Sub&lt;br /&gt;
    Private Sub btnReceive_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReceive.Click&lt;br /&gt;
        Dim myThread As New Thread(New ThreadStart(AddressOf ReceiveStart))&lt;br /&gt;
        myThread.Start()&lt;br /&gt;
    End Sub&lt;br /&gt;
    Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click&lt;br /&gt;
        Dim myThread As New Thread(New ThreadStart(AddressOf SendStart))&lt;br /&gt;
        myThread.Start()&lt;br /&gt;
    End Sub&lt;br /&gt;
&lt;br /&gt;
    Private Sub StartListen()&lt;br /&gt;
        Dim intPort As Integer&lt;br /&gt;
        Dim bidEndPoint As IPEndPoint&lt;br /&gt;
        intPort = Integer.Parse(txtPort.Text)&lt;br /&gt;
        bidEndPoint = New IPEndPoint(IPAddress.Parse(txtAddress.Text), intPort)&lt;br /&gt;
        myConnect = New Socket _&lt;br /&gt;
                     (AddressFamily.InterNetwork, _&lt;br /&gt;
                     SocketType.Stream, _&lt;br /&gt;
                     ProtocolType.Tcp)&lt;br /&gt;
        Try&lt;br /&gt;
            Dim myAsyncCallBack As New AsyncCallback(AddressOf ConnectEnd)&lt;br /&gt;
            myConnect.BeginConnect(bidEndPoint, myAsyncCallBack, myConnect)&lt;br /&gt;
            txtMessage.Text += vbCrLf + &amp;quot;Waiting...&amp;quot;&lt;br /&gt;
            Thread.Sleep(500)&lt;br /&gt;
            txtSend.Text += &amp;quot;Begin ----&amp;quot; + vbCrLf&lt;br /&gt;
            Thread.Sleep(500)&lt;br /&gt;
            txtSend.Text += &amp;quot;This is the first string ...&amp;quot; + vbCrLf&lt;br /&gt;
            Thread.Sleep(500)&lt;br /&gt;
            txtSend.Text += &amp;quot;This is the second string ....&amp;quot; + vbCrLf&lt;br /&gt;
            Thread.Sleep(500)&lt;br /&gt;
            txtSend.Text += &amp;quot;End-------&amp;quot; + vbCrLf&lt;br /&gt;
        Catch ex As SocketException&lt;br /&gt;
            Console.WriteLine(ex.Message)&lt;br /&gt;
        End Try&lt;br /&gt;
    End Sub&lt;br /&gt;
    Private Sub ConnectEnd(ByVal pIAsyncResult As IAsyncResult)&lt;br /&gt;
        myConnect.EndConnect(pIAsyncResult)&lt;br /&gt;
        txtMessage.Text += vbCrLf + &amp;quot;Successful&amp;quot;&lt;br /&gt;
    End Sub&lt;br /&gt;
    Private Sub ReceiveStart()&lt;br /&gt;
        Dim myAsyncCallBack As New AsyncCallback(AddressOf ReceiveData)&lt;br /&gt;
        myConnect.BeginReceive _&lt;br /&gt;
          (bteAccept, 0, 65536, 0, _&lt;br /&gt;
          myAsyncCallBack, myConnect)&lt;br /&gt;
        txtMessage.Text += vbCrLf + &amp;quot;Receive&amp;quot;&lt;br /&gt;
    End Sub&lt;br /&gt;
    Private Sub ReceiveData(ByVal pIAsyncResult As IAsyncResult)&lt;br /&gt;
        Dim intByte As Integer&lt;br /&gt;
        intByte = myConnect.EndReceive(pIAsyncResult)&lt;br /&gt;
        If intByte &amp;gt; 0 Then&lt;br /&gt;
            strMessage += Encoding.ASCII.GetString(bteAccept)&lt;br /&gt;
            txtSend.Text = &amp;quot;&amp;quot; + strMessage&lt;br /&gt;
        End If&lt;br /&gt;
    End Sub&lt;br /&gt;
    Private Sub SendStart()&lt;br /&gt;
        Dim myAsyncCallBack As New AsyncCallback(AddressOf SendData)&lt;br /&gt;
        bteSend = Encoding.ASCII.GetBytes(txtSend.Text)&lt;br /&gt;
        myConnect.BeginSend _&lt;br /&gt;
          (bteSend, 0, bteSend.Length, _&lt;br /&gt;
          SocketFlags.DontRoute, myAsyncCallBack, myConnect)&lt;br /&gt;
    End Sub&lt;br /&gt;
    Private Sub SendData(ByVal pIAsyncResult As IAsyncResult)&lt;br /&gt;
        Dim intSend As Integer&lt;br /&gt;
        intSend = myConnect.EndSend(pIAsyncResult)&lt;br /&gt;
        txtMessage.Text += vbCrLf + &amp;quot;Message sent&amp;quot; + intSend.ToString + &amp;quot; bytes &amp;quot;&lt;br /&gt;
    End Sub&lt;br /&gt;
    Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click&lt;br /&gt;
        myConnect.Close()&lt;br /&gt;
    End Sub&lt;br /&gt;
&lt;br /&gt;
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load&lt;br /&gt;
    End Sub&lt;br /&gt;
End Class&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>