十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
打开VS , 选择VisualBasic -- Web -- ASP.NET Web 应用程序
创新互联是一家专注于网站制作、成都网站设计与策划设计,巴林右旗网站建设哪家好?创新互联做网站,专注于网站建设十多年,网设计领域的专业建站公司;建站业务涵盖:巴林右旗等地区。巴林右旗做网站价格咨询:028-86922220
如下图:
用 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
很有意思。
原文数据全为:“00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; ”
加密后变成了:“09 51 55 F4 FB 10 6F A4 D3 E8 87 46 F8 2F 49 CD ; ”
得出这样的结果是有很多方法都可以实现的:
比如每个原数上加上个常数就可以了。
00+09=09;得出第一组加密后的数值
00+51=51;得出第二组加密后的数值
...
00+CD=CD;得出第16组加密后的数值.
加密的方法还有很多,不过这种最简单。
还有就是你给的原文太单一了,不能够更好的分析数据的规律。
如果你能把原文改为如下这段代码再去加密一下,再把加密结果贴上来看一下就好多了。
00000140h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ;
00000150h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ;
00000160h: 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 ; 00000170h: 00 10 20 30 40 50 60 70 80 90 A0 B0 C0 D0 E0 F0 ;
00000180h: 11 11 11 11 11 22 22 22 22 22 22 EE EE EE FF FF ;
以上是单片机高手团为您解答。
如果还没解决你的问题,可以加我百度HI账号。
都可以,可以用winsock,也可以自己重写SOCKET套接字.建议你如果工期紧,可以先用WINSOCK.当然最好是自己学用SOCKET套接字.这对未来开发网络通讯是很有帮助的.因为用WINSOCK有个毛病就是杀毒软件总会阻止