简体   繁体   English

什么是套接字,端口和IP地址?

[英]What are sockets, ports, and IP addresses?

您能否给我一些关于套接字/端口/ IP地址以及它们在客户端服务器程序中如何相互配合的清晰思路?

An IP address is the address of a computer on a network. IP地址是网络上计算机的地址。
A port is a number between 1 and 65535. 端口是介于1和65535之间的数字。
A socket is one half a channel of communication between two computers over a network on a particular port. 套接字是通过特定端口的网络在两台计算机之间进行通信的通道的一半。 (the other half is the corresponding socket on the other computer) (另一半是另一台计算机上的相应插槽)

A process can open a socket to a particular IP address on a specific port. 进程可以打开一个套接字到特定端口上的特定IP地址。
A process can also open a socket to receive connections from anyone on a specific port. 进程还可以打开套接字以接收来自特定端口上任何人的连接。

For more information, read Wikipedia 有关更多信息, 请阅读Wikipedia。

This is slightly too complicated to post as an answer. 这有点太复杂了,无法发布作为答案。

Here is a tutorial on TCP/IP socket programming. 是有关TCP / IP套接字编程的教程。 A PDF of the slides is available which give an introduction and sample code. 可提供幻灯片的PDF,其中提供了简介和示例代码。 I guess this could get you started. 我想这可以帮助您入门。

Also check out tutorials on your language of choice to see the specifics of the function calls in that environment. 另外,请查看有关您选择的语言的教程,以了解该环境中函数调用的详细信息。 It is basically all the same as the same principles apply, but the function calls and levels of abstraction may differ significantly. 基本上,所有相同的原理都适用,但是函数调用和抽象级别可能有很大差异。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM