套接字上的出站端口 [英] Outbound port on sockets

查看:85
本文介绍了套接字上的出站端口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在

连接上指定哪个端口用作出站端口?我有电脑的IP地址和端口号我想要连接到(不听),但是它期待我的

连接某个端口。


具体来说,我正在尝试编写一个FTP主机,而我正在尝试实现PORT命令
。从我读过的所有内容中,客户端

提供IP地址和端口号我应该在哪里

连接发送数据(如LISTing) ),它期待我通过端口20连接
。如果有人熟悉FTP并且可以告诉我

这是否属实,是否我真的需要出去港口

20,我也很感激。


谢谢。

Is it possible to specify which port to use as the outbound port on a
connection? I have the IP address and port number for the computer I''m
trying to connect to (not listening for), but it''s expecting my
connection on a certain port.

Specifically, I''m trying to write an FTP host, and I''m trying to
implement the PORT command. From everything I''ve read, the client
supplies the IP address and port number for where I''m supposed to
connect to send it data (like a LISTing), and it''s expecting me to
connect over port 20. If anyone is familiar with FTP and can tell me
whether this is true or not, whether I really need to go out on port
20, I''d appreciate it, as well.

Thanks.

推荐答案

" bmearns"写道:
"bmearns" wrote:

具体来说,我正在尝试写一个FTP主机,而我正试图实现PORT命令
。从我读过的所有内容中,客户端

提供IP地址和端口号我应该在哪里

连接发送数据(如LISTing) ),它期待我通过端口20连接
。如果有人熟悉FTP并且可以告诉我

这是否属实,是否我真的需要出去港口

20,我也很感激。
Specifically, I''m trying to write an FTP host, and I''m trying to
implement the PORT command. From everything I''ve read, the client
supplies the IP address and port number for where I''m supposed to
connect to send it data (like a LISTing), and it''s expecting me to
connect over port 20. If anyone is familiar with FTP and can tell me
whether this is true or not, whether I really need to go out on port
20, I''d appreciate it, as well.



PORT表示客户端要求服务器连接到给定的

IP /端口组合;请参阅:

http://cr.yp。 to / ftp / retr.html


服务器用于此连接的端口号无关紧要。


< / F>

PORT means that the client is asking the server to connect to the given
IP/port combination; see:

http://cr.yp.to/ftp/retr.html

the port number used by the server for this connection is irrelevant.

</F>


bmearns schrieb:
bmearns schrieb:

是否可以指定使用哪个端口作为

连接的出站端口?我有电脑的IP地址和端口号我想要连接到(不听),但是它期待我的

连接某个端口。


具体来说,我正在尝试编写一个FTP主机,而我正在尝试实现PORT命令
。从我读过的所有内容中,客户端

提供IP地址和端口号我应该在哪里

连接发送数据(如LISTing) ),它期待我通过端口20连接
。如果有人熟悉FTP并且可以告诉我

这是否属实,是否我真的需要出去港口

20,我也很感激。
Is it possible to specify which port to use as the outbound port on a
connection? I have the IP address and port number for the computer I''m
trying to connect to (not listening for), but it''s expecting my
connection on a certain port.

Specifically, I''m trying to write an FTP host, and I''m trying to
implement the PORT command. From everything I''ve read, the client
supplies the IP address and port number for where I''m supposed to
connect to send it data (like a LISTing), and it''s expecting me to
connect over port 20. If anyone is familiar with FTP and can tell me
whether this is true or not, whether I really need to go out on port
20, I''d appreciate it, as well.



AFAIK你不能做到也不需要它。 PORT命令的目的

是告诉服务器可以连接的位置 - 但是客户端对该连接的源端口没有做出任何假设。更别说NAT和

其他的东西可能会影响你。


如果防火墙有问题,请使用PASV。


Diez

AFAIK you neither can''t do that nor need it. The PORT commands purpose
is to tell where the server can connect to - but the client makes no
assumptions over the source port of that connection. Let alone NAT and
other things could come into your way.

If firewalls are a problem, use PASV.

Diez




bmearns写道

bmearns wrote

是否可以指定在

连接上用作出站端口的端口?我有电脑的IP地址和端口号我想要连接到(不听),但是它期待我的

连接某个端口。


具体来说,我正在尝试编写一个FTP主机,而我正在尝试实现PORT命令
。从我读过的所有内容中,客户端

提供IP地址和端口号我应该在哪里

连接发送数据(如LISTing) ),它期待我通过端口20连接
。如果有人熟悉FTP并且可以告诉我

这是否属实,是否我真的需要出去港口

20,我也很感激。


谢谢。
Is it possible to specify which port to use as the outbound port on a
connection? I have the IP address and port number for the computer I''m
trying to connect to (not listening for), but it''s expecting my
connection on a certain port.

Specifically, I''m trying to write an FTP host, and I''m trying to
implement the PORT command. From everything I''ve read, the client
supplies the IP address and port number for where I''m supposed to
connect to send it data (like a LISTing), and it''s expecting me to
connect over port 20. If anyone is familiar with FTP and can tell me
whether this is true or not, whether I really need to go out on port
20, I''d appreciate it, as well.

Thanks.



这是不正确的。

如果发送PORT命令,你告诉服务器建立一个

与您联系,而不是相反。在这种情况下,即使您是一个

FTP客户端,您临时接受来自FTP

服务器的出站连接。

格式正确FTP PORT命令的结果是:


PORT x,x,x,x,y,z

....其中x( s)以虚线形式表示您的IP地址,并且(x * y)表示您绑定的

TCP端口。

有关更多信息,您可以查看RFC959或查看ftplib
标准模块库中的
。同样在扭曲中你可以在模块protocols.ftp中找到很多

有用的代码。

This isn''t correct.
If you send a PORT command you''re telling server to establish a
connection with you, not the contrary. In this case, even if you are an
FTP client, you temporary ACCEPT an outbound connection from the FTP
server.
The right format of a FTP PORT command is:

PORT x,x,x,x,y,z

....where x(s) represents your IP address in dotted form and (x * y) the
TCP port you bind.
For further informations you can check RFC959 or take a look at ftplib
in standard module library. Also in twisted you can find a lot of
useful code in the module protocols.ftp.


这篇关于套接字上的出站端口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆