Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
CanguruChatServer
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
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
Fernando Erd
CanguruChatServer
Commits
94d9d90b
Commit
94d9d90b
authored
Oct 31, 2016
by
Fernando Erd
Browse files
Options
Downloads
Patches
Plain Diff
Funcionando chamando um arquivo apenas
parent
d1e5f746
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Canguru/Cliente.py
+23
-10
23 additions, 10 deletions
Canguru/Cliente.py
with
23 additions
and
10 deletions
Canguru/Cliente.py
100644 → 100755
+
23
−
10
View file @
94d9d90b
#!/usr/bin/env python
#################### Protocol #############################
# Marca - Destino - Prioridade - Tamamnho - Messagem - CRC#
###########################################################
...
...
@@ -7,8 +8,9 @@ import threading
import
sys
import
binascii
HOST
=
"
200.17.202.49
"
# Endereco IP do Servidor
PORT
=
5000
# Porta que o Servidor es
HOST
=
"
127.0.0.1
"
# Endereco IP do Servidor
SEND_PORT
=
5000
# Porta que o Servidor envia
RECV_PORT
=
5001
# Porta que o Servidor recebe
class
FuncThread
(
threading
.
Thread
):
def
__init__
(
self
,
target
,
*
args
):
...
...
@@ -21,7 +23,7 @@ class FuncThread(threading.Thread):
class
Protocol
():
def
__init__
():
self
.
marca
=
'
10101010
'
#Marca
self
.
marca
=
"
~
"
#Marca
#Get sizeof message
def
sizeof
(
self
,
msg
):
...
...
@@ -43,6 +45,9 @@ class Protocol():
print
'
Mensagem:
'
self
.
msg
=
raw_input
()
#def empacotar():
# return self.marca + self.sizemsg
#Get CRC32
def
getCRC32
(
msg
):
buff
=
(
binascii
.
crc32
(
msg
)
&
0xFFFFFFFF
)
...
...
@@ -64,7 +69,7 @@ class queue(object):
def
client
():
udp
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_DGRAM
)
dest
=
(
HOST
,
PORT
)
dest
=
(
HOST
,
SEND_
PORT
)
print
'
Para sair digite exit
\n
'
print
'
Mensagem:
'
...
...
@@ -82,16 +87,24 @@ def client ():
def
server
():
print
'
Estou no Server
'
udp
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_DGRAM
)
orig
=
(
HOST
,
PORT
)
orig
=
(
HOST
,
RECV_
PORT
)
udp
.
bind
(
orig
)
while
True
:
hostname
,
cliente
=
udp
.
recvfrom
(
1024
)
msg
,
cliente
=
udp
.
recvfrom
(
1024
)
print
cliente
,
msg
print
hostname
,
'
:
'
,
msg
print
'
Estou no Server
'
udp
.
close
()
#def killThread ():
if
len
(
sys
.
argv
)
>
1
:
AUX
=
RECV_PORT
RECV_PORT
=
SEND_PORT
SEND_PORT
=
AUX
if
__name__
==
'
__main__
'
:
threadServer
=
FuncThread
(
server
)
threadServer
.
start
()
threadClient
=
FuncThread
(
client
)
threadClient
.
start
()
threadClient
.
join
()
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