189 8069 5689

vb.net聊天程序 vb制作聊天程序

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

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

成都创新互联公司成立于2013年,是专业互联网技术服务公司,拥有项目成都网站制作、成都做网站网站策划,项目实施与项目整合能力。我们以让每一个梦想脱颖而出为使命,1280元琅琊做网站,已为上家服务,为琅琊各地企业和个人服务,联系电话:18982081108

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 怎样用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 如何实现局域网内即时会话

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

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


分享名称:vb.net聊天程序 vb制作聊天程序
网页网址:http://cdxtjz.cn/article/hhggji.html

其他资讯