Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Socket Programmierung
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dimitri Tayo Fongang Wembe
Socket Programmierung
Commits
33142427
Commit
33142427
authored
May 24, 2023
by
Dimitri Tayo Fongang Wembe
Browse files
Options
Downloads
Patches
Plain Diff
fix display error message when unexpected packet
parent
a1a231d1
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
TCPServer.java
+6
-5
6 additions, 5 deletions
TCPServer.java
UDPClient.java
+4
-0
4 additions, 0 deletions
UDPClient.java
UDPServer.java
+6
-9
6 additions, 9 deletions
UDPServer.java
with
16 additions
and
14 deletions
TCPServer.java
+
6
−
5
View file @
33142427
...
...
@@ -22,13 +22,14 @@ class TCPServer {
//clientSentence = inFromClient.readLine();
for
(
int
i
=
0
;
i
<=
1000000
;
i
++)
{
input
=
dataIn
.
readInt
();
if
(
input
!=
i
)
{
System
.
out
.
println
(
"Error"
);
}
if
(
i
!=
input
)
System
.
out
.
println
(
"Should be "
+
i
+
" but is "
+
input
);
// Gilt nur zum Testen ob der Server tatsächlich die Zahlen erhält
// Also hier print nur die ersten 99 Zahlen :-)
if
(
i
<
100
)
System
.
out
.
println
(
input
);
/*
if(i < 100)
System.out.println(input);
*/
}
//capitalizedSentence = clientSentence.toUpperCase() + '\n';
//outToClient.write(capitalizedSentence);
...
...
This diff is collapsed.
Click to expand it.
UDPClient.java
+
4
−
0
View file @
33142427
...
...
@@ -31,6 +31,10 @@ class UDPClient {
data
.
length
,
ipAddress
,
2345
);
clientSocket
.
send
(
sendPacket
);
//wait
/* for(long j = 0; j < 1000000000; j++);
for(long j = 0; j < 1000000000; j++); */
}
/* DatagramPacket sendPacket = new DatagramPacket(sendData,
...
...
This diff is collapsed.
Click to expand it.
UDPServer.java
+
6
−
9
View file @
33142427
...
...
@@ -23,17 +23,14 @@ class UDPServer {
int
inData
=
ByteBuffer
.
wrap
(
receivePacket
.
getData
(),
0
,
rcvLen
).
getInt
();
/* if(inData != i) {
System.out.println("
Error"
);
} */
if
(
i
!=
inData
)
System
.
out
.
println
(
"
Should be "
+
i
+
" but is "
+
inData
);
// Gilt nur zum Testen ob der Server tatsächlich die Zahlen erhält
// Also hier
print
nur die ersten 99 Zahlen :-)
// Also hier
sollte
nur die ersten 99 Zahlen
printen
:-)
/* if(i < 100)
System.out.println(inData); */
if
(
i
!=
inData
)
System
.
out
.
println
(
inData
);
/* String sentence = new String(receivePacket.getData(), 0, rcvLen,
"UTF-8");
...
...
@@ -50,8 +47,8 @@ class UDPServer {
i
++;
if
(
i
==
1000000
)
System
.
out
.
println
(
"end"
);
/*
if(i == 1000000)
System.out.println("end");
*/
if
(
i
>
1000000
)
{
i
=
0
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment