使用TCP / IP [英] Using TCP/IP

查看:96
本文介绍了使用TCP / IP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何查找自己的IP号码(当然使用Pythoi)。我如何向/从另外的TCP / IP套接字(已知的ip号码)发送/接收数据?


我的意思是:我做哪个模块必须使用吗?


TIA,


JB

---- ==通过新闻发布.Com - Unlimited-Uncensored-Secure Usenet News == ----
http:// www.newsfeed.com 世界排名第一的新闻组服务! > 100,000新闻组

--- = 19东/西海岸专业服务器 - 通过加密的总隐私= ---

How do I find out my own IP number (using Pythoi of course). And how do I
send/receive data to/from andother TCP/IP socket (of known ip number)?

I mean: which module do I have to use for that?

TIA,

JB
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---

推荐答案

2003年9月29日星期一21:19:26 +0200,谣言说jblazi

< jb **** @ hotmail.com>可能写得:
On Mon, 29 Sep 2003 21:19:26 +0200, rumours say that jblazi
<jb****@hotmail.com> might have written:
如何查找我自己的IP号码(当然使用Pythoi)。


一种适用于大多数系统的方法是:


导入套接字

socket.gethostbyname(socket.gethostname ())


基本上,这样您就可以请求主机名的IP地址;所以

你依赖很多变量:你的系统有一个名字,可以通过文件或DNS查找或类似的方式在本地解决......

我如何向/从另一个TCP / IP套接字(已知的ip号码)发送/接收数据?
我的意思是:我必须使用哪个模块?
How do I find out my own IP number (using Pythoi of course).
One way that works on most systems is:

import socket
socket.gethostbyname(socket.gethostname())

Basically, this way you request the IP address for your host name; so
you depend on many variables: your system has a name that can be
resolved locally by a file or DNS lookup or similar...
And how do I
send/receive data to/from andother TCP/IP socket (of known ip number)? I mean: which module do I have to use for that?




套接字模块。检查socket.socket类。

-

TZOTZIOY,我说英格兰最好,

Microsoft安全警报:Matrix开始是开放的来源。



The socket module. Check the socket.socket class.
--
TZOTZIOY, I speak England very best,
Microsoft Security Alert: the Matrix began as open source.


On Tue,2003年9月30日02:09:15 + 0300,ChristosTZOTZIOY Georgiou写道:
On Tue, 30 Sep 2003 02:09:15 +0300, Christos "TZOTZIOY" Georgiou wrote:
import socket
socket.gethostbyname(socket.gethostname())
import socket
socket.gethostbyname(socket.gethostname())




Thx。但这似乎不正常。当我启动程序

并打印结果时,我得到一个IP地址,但它不是正确的那个

即不是我目前使用的那个。 />

JB

---- ==通过Newsfeed.Com发布 - 无限制 - 未经审查 - 安全使用网新闻== ----
http://www.newsfeed.com 世界排名第一的新闻组服务! > 100,000新闻组

--- = 19东/西海岸专业服务器 - 通过加密的总隐私= ---



Thx. But this does not seem to work correctly. When I start the program
and print the result, I get an IP-address but it is not the correct one
i.e. not the one I am currently using.

JB
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---


jblazi写道:

我如何找到自己的IP号码(当然使用Pythoi)。我如何向/从另外的TCP / IP套接字(已知的ip号码)发送/接收数据?

How do I find out my own IP number (using Pythoi of course). And how do I
send/receive data to/from andother TCP/IP socket (of known ip number)?




计算机可以有多个IP地址。你怎么想

来处理有多个接口的情况

有不同的地址?


或者这只是个人代码?在这种情况下,请指定您计划运行它的

操作系统。


-Peter



A computer can have more than one IP address. How do you want
to deal with the situation where there are multiple interfaces
with different addresses?

Or is this just for personal code? In which case, please specify the
OS on which you plan to run it.

-Peter


这篇关于使用TCP / IP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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