VB.NET聊天程序

vb.net 模拟UDP通信,vb.netudp通信

Imports System.Net
Imports System.Text.Encoding

Public Class Form1
    Dim publisher As New Sockets.UdpClient(0)
    Dim subscriber As New Sockets.UdpClient(2000)



    Private Sub Timer1_Tick_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Try
            Dim ep As IPEndPoint = New IPEndPoint(IPAddress.Any, 0)
            Dim rcvbytes() As Byte = subscriber.Receive(ep)
            TextBox4.Text = ASCII.GetString(rcvbytes)
        Catch ex As Exception
        End Try
    End Sub

    Private Sub Form1_Load_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        subscriber.Client.ReceiveTimeout = 100
        subscriber.Client.Blocking = False
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        publisher.Connect(TextBox1.Text, TextBox2.Text)
        Dim sendbytes() As Byte = ASCII.GetBytes(TextBox3.Text)
        publisher.Send(sendbytes, sendbytes.Length)
    End Sub
End Class

威尼斯人线上娱乐, 

 

 

威尼斯人线上娱乐 1

http://www.bkjia.com/VBjc/1237311.htmlwww.bkjia.comtruehttp://www.bkjia.com/VBjc/1237311.htmlTechArticlevb.net 模拟UDP通信,vb.netudp通信 Imports
System.NetImports System.Text.EncodingPublic Class Form1 Dim publisher
As New Sockets.UdpClient(0) Dim subscriber As New Sockets.Ud…

文件:      Wintalk.vb

  摘要:   演示如何使用.NET Framework library创建聊天程序.

=====================================================================

Option Explicit On
Option Strict On

Imports System
Imports System.IO
Imports System.Text
Imports System.Threading
Imports System.Net
Imports System.Net.Sockets
Imports System.Drawing
Imports System.Windows.Forms
Imports Microsoft.VisualBasic

网站地图xml地图