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
68c188e9
Commit
68c188e9
authored
9 years ago
by
Vytor Calixto
Browse files
Options
Downloads
Plain Diff
Merge branch 'develop' of vsbc14/Caco into develop
parents
4e1f9996
8efd0f7b
Branches
Branches containing commit
No related tags found
1 merge request
!1
Lento
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
Message.cpp
+0
-2
0 additions, 2 deletions
Message.cpp
server.cpp
+25
-2
25 additions, 2 deletions
server.cpp
with
25 additions
and
4 deletions
Message.cpp
+
0
−
2
View file @
68c188e9
...
@@ -79,12 +79,10 @@ string Message::getDataAsString() {
...
@@ -79,12 +79,10 @@ string Message::getDataAsString() {
ostream
&
operator
<<
(
ostream
&
os
,
const
Message
&
msg
){
ostream
&
operator
<<
(
ostream
&
os
,
const
Message
&
msg
){
os
<<
'|'
<<
msg
.
begin
<<
'|'
<<
msg
.
size
<<
'|'
<<
msg
.
sequence
<<
'|'
<<
msg
.
type
<<
'|'
;
os
<<
'|'
<<
msg
.
begin
<<
'|'
<<
msg
.
size
<<
'|'
<<
msg
.
sequence
<<
'|'
<<
msg
.
type
<<
'|'
;
// os << msg.begin << msg.size << msg.sequence << msg.type;
for
(
int
i
=
0
;
i
<
msg
.
data
.
size
();
++
i
){
for
(
int
i
=
0
;
i
<
msg
.
data
.
size
();
++
i
){
os
<<
bitset
<
8
>
(
msg
.
data
[
i
]);
os
<<
bitset
<
8
>
(
msg
.
data
[
i
]);
}
}
os
<<
'|'
<<
msg
.
parity
<<
'|'
;
os
<<
'|'
<<
msg
.
parity
<<
'|'
;
// os << msg.parity;
return
os
;
return
os
;
}
}
...
...
This diff is collapsed.
Click to expand it.
server.cpp
+
25
−
2
View file @
68c188e9
...
@@ -37,7 +37,7 @@ int main(){
...
@@ -37,7 +37,7 @@ int main(){
receiveProtocol
.
reset
();
receiveProtocol
.
reset
();
receiveProtocol
.
receive
(
sockt
,
SIZE
,
WAIT_STOP
,
false
);
receiveProtocol
.
receive
(
sockt
,
SIZE
,
WAIT_STOP
,
false
);
cout
<<
"fileSize: "
<<
receiveProtocol
.
getDataAsString
()
<<
endl
;
cout
<<
"fileSize: "
<<
receiveProtocol
.
getDataAsString
()
<<
endl
;
int
fileSize
=
stoi
(
receiveProtocol
.
getDataAsString
());
unsigned
long
long
fileSize
=
stoi
(
receiveProtocol
.
getDataAsString
());
sendProtocol
.
reset
();
sendProtocol
.
reset
();
if
(
hasEnoughSpace
(
fileSize
)){
if
(
hasEnoughSpace
(
fileSize
)){
sendProtocol
.
setData
(
vector
<
BYTE
>
(
1
,(
BYTE
)
0
),
OK
);
sendProtocol
.
setData
(
vector
<
BYTE
>
(
1
,(
BYTE
)
0
),
OK
);
...
@@ -45,6 +45,7 @@ int main(){
...
@@ -45,6 +45,7 @@ int main(){
}
else
{
}
else
{
sendProtocol
.
setData
(
vector
<
BYTE
>
(
1
,(
BYTE
)
SPACE_ERR
),
ERROR
);
sendProtocol
.
setData
(
vector
<
BYTE
>
(
1
,(
BYTE
)
SPACE_ERR
),
ERROR
);
sendProtocol
.
sendMessage
(
sockt
,
0
);
sendProtocol
.
sendMessage
(
sockt
,
0
);
continue
;
}
}
receiveProtocol
.
reset
();
receiveProtocol
.
reset
();
receiveProtocol
.
receive
(
sockt
,
DATA
,
SLIDING
,
true
);
receiveProtocol
.
receive
(
sockt
,
DATA
,
SLIDING
,
true
);
...
@@ -52,12 +53,34 @@ int main(){
...
@@ -52,12 +53,34 @@ int main(){
writeFile
(
getWorkingPath
()
+
"/"
+
fileName
,
receiveProtocol
.
getData
());
writeFile
(
getWorkingPath
()
+
"/"
+
fileName
,
receiveProtocol
.
getData
());
}
else
if
(
status
==
GET
){
}
else
if
(
status
==
GET
){
//TODO
string
filePath
=
getWorkingPath
()
+
"/"
+
receiveProtocol
.
getDataAsString
();
if
(
fexists
(
filePath
))
{
string
size
=
to_string
(
filesize
(
filePath
));
cout
<<
"ARQUIVO: "
<<
filePath
<<
"|"
<<
size
<<
endl
;
sendProtocol
.
setData
(
vector
<
BYTE
>
(
size
.
begin
(),
size
.
end
()),
SIZE
);
sendProtocol
.
sendMessage
(
sockt
,
0
);
int
error
=
receiveProtocol
.
receive
(
sockt
,
OK
,
WAIT_STOP
,
false
);
if
(
error
<
0
)
continue
;
sendProtocol
.
reset
();
ifstream
putFile
(
filePath
);
stringstream
buffer
;
buffer
<<
putFile
.
rdbuf
();
string
data
=
buffer
.
str
();
sendProtocol
.
setData
(
vector
<
BYTE
>
(
data
.
begin
(),
data
.
end
()),
DATA
);
sendProtocol
.
transmit
(
sockt
,
SLIDING
);
}
else
{
sendProtocol
.
setData
(
vector
<
BYTE
>
(
1
,(
BYTE
)
DIR_ERR
),
ERROR
);
sendProtocol
.
sendMessage
(
sockt
,
0
);
continue
;
}
}
else
if
(
status
==
ENDTX
){
}
else
if
(
status
==
ENDTX
){
sendProtocol
.
reset
();
sendProtocol
.
reset
();
vector
<
BYTE
>
val
(
1
,(
BYTE
)
receiveProtocol
.
getMessages
().
back
().
sequence
.
to_ulong
());
vector
<
BYTE
>
val
(
1
,(
BYTE
)
receiveProtocol
.
getMessages
().
back
().
sequence
.
to_ulong
());
sendProtocol
.
setData
(
val
,
ACK
);
sendProtocol
.
setData
(
val
,
ACK
);
sendProtocol
.
sendMessages
(
sockt
);
sendProtocol
.
sendMessages
(
sockt
);
}
else
if
(
status
<
0
&&
status
!=
NOISE
){
sendProtocol
.
setData
(
vector
<
BYTE
>
(
1
,(
BYTE
)
NACK
),
ERROR
);
sendProtocol
.
sendMessage
(
sockt
,
0
);
}
}
}
catch
(
char
const
*
strException
){
}
catch
(
char
const
*
strException
){
cout
<<
"Erro:"
<<
strException
<<
endl
;
cout
<<
"Erro:"
<<
strException
<<
endl
;
...
...
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