简体   繁体   中英

What are sockets, ports, and IP addresses?

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

An IP address is the address of a computer on a network.
A port is a number between 1 and 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.
A process can also open a socket to receive connections from anyone on a specific port.

For more information, read Wikipedia

This is slightly too complicated to post as an answer.

Here is a tutorial on TCP/IP socket programming. A PDF of the slides is available which give an introduction and sample code. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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