Private Sub Form_Load()
泌陽(yáng)網(wǎng)站建設(shè)公司創(chuàng)新互聯(lián),泌陽(yáng)網(wǎng)站設(shè)計(jì)制作,有大型網(wǎng)站制作公司豐富經(jīng)驗(yàn)。已為泌陽(yáng)1000多家提供企業(yè)網(wǎng)站建設(shè)服務(wù)。企業(yè)網(wǎng)站搭建\成都外貿(mào)網(wǎng)站建設(shè)要多少錢,請(qǐng)找那個(gè)售后服務(wù)好的泌陽(yáng)做網(wǎng)站的公司定做!
With Winsock1
.RemoteHost = "124.135.13.106" '對(duì)方的IP
.RemotePort = 1002 ' 對(duì)方的端口號(hào)
.Bind 1001 ' 本機(jī)的端口號(hào)
End With
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim strData As String
Winsock1.GetData strData '接收字節(jié)
List1.AddItem strData
End Sub
這個(gè)用UDP進(jìn)行連接的。只不過(guò)是對(duì)單個(gè)機(jī)器進(jìn)行的。
用VB5 Winsock控件創(chuàng)建TCP/IP通訊程序 隨著Windows 95中文版和Windows NT Server 4.0中文版的流行, Microsoft公司推出了相應(yīng)平臺(tái)上的開(kāi)發(fā)軟件: Visual Basic 5.0 中文企業(yè) 版。它為Windows環(huán)境下的網(wǎng)絡(luò)開(kāi)發(fā)提供了強(qiáng)大的工具,Winsock控件就是其中之一。 Winsock控件建立在TCP、UDP協(xié)議的基礎(chǔ)上,完成與遠(yuǎn)程計(jì)算機(jī)的通信。即使對(duì)TCP/IP不太熟悉的用戶,使用該控件也可以在十幾分鐘內(nèi)創(chuàng)建一個(gè)簡(jiǎn)單的客戶機(jī)/服務(wù)器程序。下面我們對(duì)Winsock控件的事件、方法、屬性按其在程序中出現(xiàn)的順序分別作詳細(xì)的介紹,以便更好地理解程序源代碼。
具體的源碼太長(zhǎng)了,這里發(fā)不了。大概步驟給你說(shuō)一下吧,使用winsocket進(jìn)行通信,局域網(wǎng)可以使用udp完成通信。主要就是配置IP 端口號(hào)什么的。
用 vb.net socket通信
Dim th As Threading.Thread
2 Dim tcpl As System.Net.Sockets.TcpListener
3
4 Private Sub Form1_Load()Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
5 th = New System.Threading.Thread(New System.Threading.ThreadStart(AddressOf MyListen))
6 th.Start()
7 End Sub
8
9 Public Sub SendMessage()Sub SendMessage(ByVal IP As String, ByVal SendMsg As String)
10 Try
11 If IP "" Then
12 Dim tcpc As New System.Net.Sockets.TcpClient(IP, 5656)
13 Dim tcpStream As Net.Sockets.NetworkStream = tcpc.GetStream
14 Dim reqStream As New IO.StreamWriter(tcpStream)
15 reqStream.Write(SendMsg)
16 reqStream.Flush()
17 tcpStream.Close()
18 tcpc.Close()
19 End If
20 Catch ex As Exception
21 MsgBox(ex.Message.ToString)
22 End Try
23 End Sub
24 Private Sub MyListen()Sub MyListen()
25 Try
26 Dim ipAddress As System.Net.IPAddress = System.Net.Dns.Resolve(System.Net.Dns.GetHostName).AddressList(0)
27 tcpl = New System.Net.Sockets.TcpListener(ipAddress, 5656)
28 tcpl.Start()
29 While True
30 Dim s As System.Net.Sockets.Socket = tcpl.AcceptSocket()
31 Dim MyBuffer(1024) As Byte
32 Dim i As Integer
33 i = s.Receive(MyBuffer)
34 If i 0 Then
35 Dim lstrRec As String
36 Dim j As Integer
37 For j = 0 To i - 1
38 TextBox1.Text += Chr(MyBuffer(j)) ","
39 Next
40 End If
41 End While
42 Catch ex As Exception
43 MsgBox(ex.Message.ToString)
44 End Try
45 End Sub
46
47 Private Sub Button1_Click()Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
48 SendMessage("192.168.0.61", TextBox2.Text)
49 End Sub
樓主你好,你所指的那個(gè)指令就是"winchat",Windows自帶的局域網(wǎng)聊天工具.使用方法:開(kāi)始--運(yùn)行--輸入winchat,就可以打開(kāi)Winchat了.只能實(shí)現(xiàn)很簡(jiǎn)單的功能,并且是中文,沒(méi)什么好介紹的,相信你一看就懂,希望可以幫到你!
ps:你所說(shuō)的電影是杜拉拉升職記吧?貌似那是用的郵件發(fā)的,不小心點(diǎn)成群發(fā)了~嘿嘿..