大橙子网站建设,新征程启航

为企业提供网站建设、域名注册、服务器等服务

vb.net聊天程序 VBNET教程

VB.net Socket

麻烦给我发下vb2010下Socket类的使用方法,最好是有代码。就是怎样实现同一台电脑上两个程序的通讯,1窗体有按钮,文本框,2窗体有文本框,当单机1窗体的按钮时该窗体文本框的内容在2窗体的文本框中显示。。。十万火急啊。 邮箱523484850@qq.com

创新互联专注为客户提供全方位的互联网综合服务,包含不限于网站制作、网站设计、新县网络推广、微信小程序开发、新县网络营销、新县企业策划、新县品牌公关、搜索引擎seo、人物专访、企业宣传片、企业代运营等,从售前售中售后,我们都将竭诚为您服务,您的肯定,是我们最大的嘉奖;创新互联为所有大学生创业者提供新县建站搭建服务,24小时服务热线:18980820575,官方网址:www.cdcxhl.com

vb.net 怎样用UDP 协议 写一个聊天程序啊?如图

'xiansr.2014/2/7 vb.net2010 调试通过

Imports System.Net

Imports System.Net.Sockets

Imports System.Text

Public Class Form1

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click

Dim udpClient As New UdpClient(11000)

Try

udpClient.Connect("127.0.0.1", 11000)

Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes(RichTextBox1.Text)

udpClient.Send(sendBytes, sendBytes.Length)

Dim RemoteIpEndPoint As New IPEndPoint(IPAddress.Any, 0)

Dim receiveBytes As [Byte]() = udpClient.Receive(RemoteIpEndPoint)

Dim returnData As String = Encoding.ASCII.GetString(receiveBytes)

RichTextBox2.Text = "接收到: " + returnData.ToString()

'Debug.Print(("This message was sent from " + RemoteIpEndPoint.Address.ToString() + " on their port number " + RemoteIpEndPoint.Port.ToString()))

udpClient.Close()

Catch ex As Exception

stop

End Try

End Sub

End Class

vb.net编写的聊天程序怎么不能传送汉字

‘客户端向这样写:在窗体说放两个文本框、两个标签、两个按钮、一个列表框

Imports System.Net

Imports System.Net.Sockets

Imports System.IO

Imports System.Threading

Public Class Form1

'网络基础数据流

Private ns As NetworkStream

Private swriter As StreamWriter

Private nsread As StreamReader

Private tcpclient As TcpClient

Private tcpconnected As Boolean = False

Private clisocket As Socket

Private mythread As Thread

'发送

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

If Me.TextBox2.Text "" Then

swriter.WriteLine(Me.TextBox2.Text)

swriter.Flush()

Me.TextBox2.Text = ""

Else

MessageBox.Show("发送信息不能为空!", "错误提示")

End If

End Sub

Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)

If disposing Then

If Not (components Is Nothing) Then

components.Dispose()

End If

End If

MyBase.Dispose(disposing)

End Sub

'建立连连接

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

Dim ipremote As IPAddress

Dim tcpclient As TcpClient

Try

ipremote = IPAddress.Parse(Me.TextBox1.Text)

Catch ex As Exception

MessageBox.Show("IP地址不合法!", "错误提示")

End Try

Try

tcpclient = New TcpClient(Me.TextBox1.Text, 8000)

ns = tcpclient.GetStream

swriter = New StreamWriter(ns)

Me.StatusBar1.Text = "已经连接上"

Me.Button2.Enabled = False

Me.Button1.Enabled = True

tcpconnected = True

Catch ex As Exception

MessageBox.Show("无法与远程8000端口建立连接!", "错误提示")

End Try

End Sub

Private Sub listen()

Try

Dim tcplistener As New TcpListener(IPAddress.Parse("127.0.0.1"), 8000)

tcplistener.Start()

tcpclient = tcplistener.AcceptTcpClient

ns = tcpclient.GetStream()

nsread = New StreamReader(ns)

While True

Dim msg As String = nsread.ReadLine

If msg = "stop" Then

tcplistener.Stop()

ns.Close()

nsread.Close()

mythread.Abort()

Else

Dim mytime As String = DateTime.Now.ToShortTimeString

Me.ListBox1.Items.Add(mytime + " " + msg)

End If

End While

Catch ex As System.Security.SecurityException

MessageBox.Show("侦听失败!", "错误")

End Try

End Sub

End Class

VB.NET 如何实现局域网内即时会话

楼主你好,你所指的那个指令就是"winchat",Windows自带的局域网聊天工具.使用方法:开始--运行--输入winchat,就可以打开Winchat了.只能实现很简单的功能,并且是中文,没什么好介绍的,相信你一看就懂,希望可以帮到你!

ps:你所说的电影是杜拉拉升职记吧?貌似那是用的邮件发的,不小心点成群发了~嘿嘿..


本文标题:vb.net聊天程序 VBNET教程
当前链接:http://dzwzjz.com/article/hiphcj.html
在线咨询
服务热线
服务热线:028-86922220
TOP