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
37058af0
Commit
37058af0
authored
Aug 04, 1995
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new sendport() interface; add test() program call
parent
040d200c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
6 deletions
+9
-6
Lib/ftplib.py
Lib/ftplib.py
+9
-6
No files found.
Lib/ftplib.py
View file @
37058af0
...
@@ -198,10 +198,8 @@ class FTP:
...
@@ -198,10 +198,8 @@ class FTP:
self
.
voidresp
()
self
.
voidresp
()
# Send a PORT command with the current host and the given port number
# Send a PORT command with the current host and the given port number
def
sendport
(
self
,
port
):
def
sendport
(
self
,
host
,
port
):
hostname
=
socket
.
gethostname
()
hbytes
=
string
.
splitfields
(
host
,
'.'
)
hostaddr
=
socket
.
gethostbyname
(
hostname
)
hbytes
=
string
.
splitfields
(
hostaddr
,
'.'
)
pbytes
=
[
`port/256`
,
`port%256`
]
pbytes
=
[
`port/256`
,
`port%256`
]
bytes
=
hbytes
+
pbytes
bytes
=
hbytes
+
pbytes
cmd
=
'PORT '
+
string
.
joinfields
(
bytes
,
','
)
cmd
=
'PORT '
+
string
.
joinfields
(
bytes
,
','
)
...
@@ -213,8 +211,9 @@ class FTP:
...
@@ -213,8 +211,9 @@ class FTP:
sock
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
sock
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
sock
.
bind
((
''
,
0
))
sock
.
bind
((
''
,
0
))
sock
.
listen
(
1
)
sock
.
listen
(
1
)
host
,
port
=
sock
.
getsockname
()
dummyhost
,
port
=
sock
.
getsockname
()
# Get proper port
resp
=
self
.
sendport
(
port
)
host
,
dummyport
=
self
.
sock
.
getsockname
()
# Get proper host
resp
=
self
.
sendport
(
host
,
port
)
return
sock
return
sock
# Send a port command and a transfer command, accept the connection
# Send a port command and a transfer command, accept the connection
...
@@ -439,3 +438,7 @@ def test():
...
@@ -439,3 +438,7 @@ def test():
ftp
.
retrbinary
(
'RETR '
+
file
,
\
ftp
.
retrbinary
(
'RETR '
+
file
,
\
sys
.
stdout
.
write
,
1024
)
sys
.
stdout
.
write
,
1024
)
ftp
.
quit
()
ftp
.
quit
()
if
__name__
==
'__main__'
:
test
()
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