Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tftp_etape2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pierre.johner
tftp_etape2
Commits
3d722a10
There was a problem fetching the pipeline summary.
Commit
3d722a10
authored
8 years ago
by
pierre.johner
Browse files
Options
Downloads
Patches
Plain Diff
Upload new file
parent
ef4b3ada
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Pipeline
#
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
packet_class.py
+29
-0
29 additions, 0 deletions
packet_class.py
with
29 additions
and
0 deletions
packet_class.py
0 → 100644
+
29
−
0
View file @
3d722a10
import
struct
import
socket
import
simu_perte_class
class
Packet
:
def
__init__
(
self
,
opCode
,
fileName
=
None
,
block
=
None
,
data
=
None
):
mode
=
"
octet
"
if
(
opCode
==
1
or
opCode
==
2
):
self
.
p
=
struct
.
pack
(
'
>h
'
+
str
(
len
(
fileName
))
+
'
s
'
+
'
?
'
+
str
(
len
(
mode
))
+
'
s
'
+
'
?
'
,
opCode
,
fileName
,
0
,
mode
,
0
)
elif
(
opCode
==
3
):
self
.
p
=
struct
.
pack
(
'
>hh
'
+
str
(
len
(
data
))
+
'
s
'
,
opCode
,
block
,
data
)
elif
(
opCode
==
4
):
self
.
p
=
struct
.
pack
(
'
>hh
'
,
opCode
,
block
)
elif
(
opCode
==
5
):
self
.
p
=
struct
.
pack
(
'
>hh
'
++
str
(
len
(
errorMsg
))
+
'
s?
'
,
opCode
,
errorCode
,
errorMsg
,
0
)
def
send
(
self
,
canal
):
print
(
"
Try to send Packet
"
)
canal
.
send
(
self
.
p
)
def
receive
(
self
,
canal
):
print
(
"
Try to receive Packet
"
)
d
=
canal
.
receive
()
return
d
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
register
or
sign in
to comment