Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
78f0bf71
Commit
78f0bf71
authored
Aug 25, 2000
by
Jeremy Hylton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update demo scripts to use addr tuples for bind and connect
closes bug #111928
parent
99ca67ce
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
9 additions
and
9 deletions
+9
-9
Demo/sockets/finger.py
Demo/sockets/finger.py
+1
-1
Demo/sockets/ftp.py
Demo/sockets/ftp.py
+2
-2
Demo/sockets/rpythond.py
Demo/sockets/rpythond.py
+1
-1
Demo/sockets/telnet.py
Demo/sockets/telnet.py
+1
-1
Demo/sockets/throughput.py
Demo/sockets/throughput.py
+2
-2
Demo/sockets/udpecho.py
Demo/sockets/udpecho.py
+2
-2
No files found.
Demo/sockets/finger.py
View file @
78f0bf71
...
...
@@ -23,7 +23,7 @@ FINGER_PORT = 79
#
def
finger
(
host
,
args
):
s
=
socket
(
AF_INET
,
SOCK_STREAM
)
s
.
connect
(
host
,
FINGER_PORT
)
s
.
connect
(
(
host
,
FINGER_PORT
)
)
s
.
send
(
args
+
'
\
n
'
)
while
1
:
buf
=
s
.
recv
(
1024
)
...
...
Demo/sockets/ftp.py
View file @
78f0bf71
...
...
@@ -48,7 +48,7 @@ def control(hostname):
# Create control connection
#
s
=
socket
(
AF_INET
,
SOCK_STREAM
)
s
.
connect
(
hostname
,
FTP_PORT
)
s
.
connect
(
(
hostname
,
FTP_PORT
)
)
f
=
s
.
makefile
(
'r'
)
# Reading the replies is easier from a file...
#
# Control loop
...
...
@@ -79,7 +79,7 @@ def newdataport(s, f):
port
=
nextport
+
FTP_DATA_PORT
nextport
=
(
nextport
+
1
)
%
16
r
=
socket
(
AF_INET
,
SOCK_STREAM
)
r
.
bind
(
gethostbyname
(
gethostname
()),
port
)
r
.
bind
(
(
gethostbyname
(
gethostname
()),
port
)
)
r
.
listen
(
1
)
sendportcmd
(
s
,
f
,
port
)
return
r
...
...
Demo/sockets/rpythond.py
View file @
78f0bf71
...
...
@@ -19,7 +19,7 @@ def main():
else
:
port
=
PORT
s
=
socket
(
AF_INET
,
SOCK_STREAM
)
s
.
bind
(
''
,
port
)
s
.
bind
(
(
''
,
port
)
)
s
.
listen
(
1
)
while
1
:
conn
,
(
remotehost
,
remoteport
)
=
s
.
accept
()
...
...
Demo/sockets/telnet.py
View file @
78f0bf71
...
...
@@ -51,7 +51,7 @@ def main():
s
=
socket
(
AF_INET
,
SOCK_STREAM
)
#
try
:
s
.
connect
(
host
,
port
)
s
.
connect
(
(
host
,
port
)
)
except
error
,
msg
:
sys
.
stderr
.
write
(
'connect failed: '
+
`msg`
+
'
\
n
'
)
sys
.
exit
(
1
)
...
...
Demo/sockets/throughput.py
View file @
78f0bf71
...
...
@@ -44,7 +44,7 @@ def server():
else
:
port
=
MY_PORT
s
=
socket
(
AF_INET
,
SOCK_STREAM
)
s
.
bind
(
''
,
port
)
s
.
bind
(
(
''
,
port
)
)
s
.
listen
(
1
)
print
'Server ready...'
while
1
:
...
...
@@ -72,7 +72,7 @@ def client():
t1
=
time
.
time
()
s
=
socket
(
AF_INET
,
SOCK_STREAM
)
t2
=
time
.
time
()
s
.
connect
(
host
,
port
)
s
.
connect
(
(
host
,
port
)
)
t3
=
time
.
time
()
i
=
0
while
i
<
count
:
...
...
Demo/sockets/udpecho.py
View file @
78f0bf71
...
...
@@ -33,7 +33,7 @@ def server():
else
:
port
=
ECHO_PORT
s
=
socket
(
AF_INET
,
SOCK_DGRAM
)
s
.
bind
(
''
,
port
)
s
.
bind
(
(
''
,
port
)
)
print
'udp echo server ready'
while
1
:
data
,
addr
=
s
.
recvfrom
(
BUFSIZE
)
...
...
@@ -50,7 +50,7 @@ def client():
port
=
ECHO_PORT
addr
=
host
,
port
s
=
socket
(
AF_INET
,
SOCK_DGRAM
)
s
.
bind
(
''
,
0
)
s
.
bind
(
(
''
,
0
)
)
print
'udp echo client ready, reading stdin'
while
1
:
line
=
sys
.
stdin
.
readline
()
...
...
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