Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Caco
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Harbor Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Vytor Calixto
Caco
Commits
cc28a42f
Commit
cc28a42f
authored
9 years ago
by
Vytor Calixto
Browse files
Options
Downloads
Patches
Plain Diff
Sending lsr to server
parent
13cf73e5
Branches
Branches containing commit
No related tags found
1 merge request
!1
Lento
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
Message.cpp
+16
-1
16 additions, 1 deletion
Message.cpp
Protocol.cpp
+3
-1
3 additions, 1 deletion
Protocol.cpp
Protocol.h
+1
-1
1 addition, 1 deletion
Protocol.h
client.cpp
+19
-1
19 additions, 1 deletion
client.cpp
definitions.h
+1
-0
1 addition, 0 deletions
definitions.h
server.cpp
+1
-1
1 addition, 1 deletion
server.cpp
with
41 additions
and
5 deletions
Message.cpp
+
16
−
1
View file @
cc28a42f
...
...
@@ -19,7 +19,22 @@ bool Message::checkParity() {
string
Message
::
getSendData
()
{
calcParity
();
string
s
(
data
.
begin
(),
data
.
end
());
string
d
=
header
.
c_ctrl
.
begin
+
header
.
c_ctrl
.
sizeSeq
+
header
.
c_ctrl
.
seqType
+
s
.
c_str
()
+
header
.
c_ctrl
.
parity
;
int
size
=
data
.
size
();
//TODO: quebrar em partes aqui? ou tem que quebrar no protocolo?
header
.
i_ctrl
.
size
=
size
;
header
.
i_ctrl
.
sequence
=
1
;
char
*
fill
;
if
(
size
<
63
)
{
fill
=
(
char
*
)
malloc
((
63
-
size
)
*
sizeof
(
char
));
memset
(
fill
,
0
,
(
63
-
size
)
*
sizeof
(
char
));
}
string
d
;
d
+=
header
.
c_ctrl
.
begin
;
d
+=
header
.
c_ctrl
.
sizeSeq
;
d
+=
header
.
c_ctrl
.
seqType
;
d
+=
s
.
c_str
();
d
+=
fill
;
d
+=
header
.
c_ctrl
.
parity
;
return
d
;
}
...
...
This diff is collapsed.
Click to expand it.
Protocol.cpp
+
3
−
1
View file @
cc28a42f
...
...
@@ -10,9 +10,10 @@ void Protocol::setMessages(vector<Message> messages){
this
->
messages
=
messages
;
}
bool
Protocol
::
send
(
int
socket
,
int
window
)
{
bool
Protocol
::
send
Messages
(
int
socket
,
int
window
)
{
for
(
int
i
=
0
;
i
<
messages
.
size
();
++
i
)
{
string
data
=
messages
[
i
].
getSendData
();
send
(
socket
,
data
.
c_str
(),
messages
[
i
].
header
.
i_ctrl
.
size
,
0
);
}
return
true
;
}
...
...
@@ -70,6 +71,7 @@ void Protocol::setData(vector<BYTE> data, int type){
int
Protocol
::
recvMessage
(
int
sockt
){
BYTE
dataRec
[
MAXSIZE
+
4
];
recv
(
sockt
,
dataRec
,
MAXSIZE
,
0
);
cout
<<
dataRec
[
0
]
<<
dataRec
[
1
]
<<
dataRec
[
2
]
<<
"|
\t
"
;
Message
msg
;
msg
.
header
.
c_ctrl
.
begin
=
dataRec
[
0
];
if
(
msg
.
header
.
i_ctrl
.
begin
!=
BEGIN
){
...
...
This diff is collapsed.
Click to expand it.
Protocol.h
+
1
−
1
View file @
cc28a42f
...
...
@@ -9,7 +9,7 @@ private:
vector
<
Message
>
messages
;
int
timeout
;
public:
bool
send
(
int
socket
,
int
window
);
bool
send
Messages
(
int
socket
,
int
window
);
vector
<
Message
>
getMessages
();
void
setMessages
(
vector
<
Message
>
messages
);
vector
<
BYTE
>
getData
();
...
...
This diff is collapsed.
Click to expand it.
client.cpp
+
19
−
1
View file @
cc28a42f
...
...
@@ -35,7 +35,7 @@ int main(){
msg
.
header
.
i_ctrl
.
type
=
LS
;
msg
.
data
=
vector
<
BYTE
>
(
line
.
begin
(),
line
.
end
());
protocol
.
addMessage
(
msg
);
protocol
.
send
(
sockt
,
WAIT_STOP
);
protocol
.
send
Messages
(
sockt
,
WAIT_STOP
);
// TODO: imprimir resposta
}
else
if
(
command
==
"put"
){
//TODO
...
...
@@ -52,6 +52,24 @@ int main(){
}
catch
(
out_of_range
e
){
cerr
<<
"Error: Esse comando requer argumentos."
<<
endl
;
}
int
status
=
protocol
.
recvMessage
(
sockt
);
if
(
status
>
0
){
if
(
status
==
ENDTX
){
protocol
=
Protocol
();
//TODO: send ACK
}
else
if
(
status
==
CD
){
cd
(
protocol
.
getDataAsString
());
}
else
if
(
status
==
LS
){
cout
<<
"Recebeu LS
\n
"
;
string
output
=
ls
(
protocol
.
getDataAsString
());
//TODO: send output back
}
else
if
(
status
==
PUT
){
//TODO
}
else
if
(
status
==
GET
){
//TODO
}
}
}
return
0
;
}
...
...
This diff is collapsed.
Click to expand it.
definitions.h
+
1
−
0
View file @
cc28a42f
...
...
@@ -4,6 +4,7 @@
#include
<iostream>
#include
<string.h>
#include
<vector>
#include
<cstdlib>
using
namespace
std
;
...
...
This diff is collapsed.
Click to expand it.
server.cpp
+
1
−
1
View file @
cc28a42f
...
...
@@ -16,7 +16,7 @@ int main(){
}
else
if
(
status
==
CD
){
cd
(
protocol
.
getDataAsString
());
}
else
if
(
status
==
LS
){
cout
<<
"Recebeu LS"
;
cout
<<
"Recebeu LS
\n
"
;
string
output
=
ls
(
protocol
.
getDataAsString
());
//TODO: send output back
}
else
if
(
status
==
PUT
){
...
...
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