Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
U
uva
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
uva
Commits
b691a5fa
Commit
b691a5fa
authored
Feb 04, 2011
by
Sander van Veen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added initial version of client.py.
parent
e47c4809
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
0 deletions
+34
-0
telematica/ass1/client.py
telematica/ass1/client.py
+34
-0
No files found.
telematica/ass1/client.py
0 → 100644
View file @
b691a5fa
import
socket
class
Client
:
"""
Chat client
"""
def
__init__
(
self
):
self
.
sock
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
def
connect
(
self
,
host
,
port
):
self
.
sock
.
connect
((
host
,
port
))
def
send
(
self
,
msg
):
totalsent
=
0
while
totalsent
<
MSGLEN
:
sent
=
self
.
sock
.
send
(
msg
[
totalsent
:])
if
not
sent
:
raise
RuntimeError
(
"socket connection broken"
)
totalsent
=
totalsent
+
sent
def
receive
(
self
):
msg
=
''
while
len
(
msg
)
<
MSGLEN
:
chunk
=
self
.
sock
.
recv
(
MSGLEN
-
len
(
msg
))
if
not
chunk
:
raise
RuntimeError
(
"socket connection broken"
)
msg
=
msg
+
chunk
return
msg
if
__name__
==
'__main__'
:
client
=
Client
()
client
.
connect
(
'ow150.science.uva.nl'
,
16897
)
print
'< %s'
%
client
.
receive
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment