FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Simple.BasicNet/Client/Program.cs at main · SimpleZDM/Simple.BasicNet · GitHub
SimpleZDM
Simple.BasicNet
Repository navigation
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Simple.BasicNet
/
Client
/
Program.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
80 lines (70 loc) · 1.76 KB
Breadcrumbs
Simple.BasicNet
/
Client
/
Program.cs
Copy path
File metadata and controls
80 lines (70 loc) · 1.76 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
using
System
.
Diagnostics
;
using
System
.
Net
;
using
System
.
Net
.
Http
.
Headers
;
using
System
.
Net
.
Sockets
;
using
System
.
Text
;
public
class
Progarm
{
public
static
void
Main
(
string
[
]
args
)
{
data1
=
new
byte
[
]
{
0xB
,
0xC
,
0xB
,
0xF
,
0x11
}
;
//11
data2
=
new
byte
[
]
{
0xB
,
0xC
,
0x16
,
0xF
,
0x11
}
;
//22=16+6
data3
=
new
byte
[
]
{
0x21
,
0xC
,
0x21
,
0xF
,
0x11
}
;
//33 16*2+1
data4
=
new
byte
[
]
{
0x2D
,
0xC
,
0x2C
,
0xF
,
0x11
}
;
//44 16*2+12
StarTest
(
)
;
}
public
static
void
StarTest
(
)
{
string
strIp
=
"172.16.1.128"
;
IPAddress
.
TryParse
(
"172.16.1.128"
,
out
IPAddress
ip
)
;
int
Port
=
1234
;
IPEndPoint
endPoint
=
new
IPEndPoint
(
ip
,
1234
)
;
Socket
socket
=
new
Socket
(
AddressFamily
.
InterNetwork
,
SocketType
.
Stream
,
ProtocolType
.
Tcp
)
;
socket
.
Connect
(
endPoint
)
;
int
length
=
0
;
byte
[
]
bufferContain
=
new
byte
[
1024
]
;
byte
[
]
buffer
=
new
byte
[
1024
]
;
Console
.
WriteLine
(
"#################链接成功################"
)
;
Console
.
WriteLine
(
$
"#################服务器地址:
{
strIp
}
################"
)
;
Console
.
WriteLine
(
$
"#################端口:
{
Port
}
################"
)
;
Task
.
Run
(
(
)
=>
{
while
(
true
)
{
length
=
socket
.
Receive
(
bufferContain
)
;
buffer
=
new
byte
[
length
]
;
Array
.
Copy
(
bufferContain
,
buffer
,
length
)
;
Console
.
WriteLine
(
Encoding
.
UTF8
.
GetString
(
buffer
)
)
;
}
}
)
;
while
(
true
)
{
string
cmd
=
Console
.
ReadLine
(
)
;
int
.
TryParse
(
cmd
,
out
int
cmdId
)
;
if
(
cmdId
<=
0
)
break
;
switch
(
cmdId
)
{
case
1
:
socket
.
Send
(
data1
)
;
break
;
case
2
:
socket
.
Send
(
data2
)
;
break
;
case
3
:
socket
.
Send
(
data3
)
;
break
;
case
4
:
socket
.
Send
(
data4
)
;
break
;
default
:
break
;
}
}
}
public
static
byte
[
]
data1
;
public
static
byte
[
]
data2
;
public
static
byte
[
]
data3
;
public
static
byte
[
]
data4
;
}
Back
|
FazBrowse Home
|
New Git URL