套接字连接和tcp连接之间有什么区别? [英] Any difference between socket connection and tcp connection?

查看:933
本文介绍了套接字连接和tcp连接之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这两个概念是否指的是同一件事?他们有区别吗?

Are these 2 concepts refer to the same thing? Do they have difference?

在我看来,它们是不同的,并且套接字连接基于tcp连接.一个套接字包含一个IP地址和端口,它只能连接到另一个套接字,但是同一计算机上的IP地址和端口可以通过TCP连接与许多其他IP地址和端口连接.是这样吗?

In my opinion, they are different, and socket connection is based on tcp connection. A socket contains an IP address and port and it could only connect to another socket, but an IP address and port in the same machine could be connected with many other IP addresses and ports with TCP connection. Is this right?

推荐答案

TCP/IP是用于通信的协议栈,套接字是(双向)通信中的端点.套接字不必基于TCP,但通常是这种情况.套接字一词通常也用于指由操作系统提供的API,该API允许您通过TCP/IP堆栈进行连接,例如,Winsock API为Windows上的TCP/IP堆栈提供了用于连接的API.

TCP/IP is a protocol stack for communication, a socket is an endpoint in a (bidirectional) communication. A socket need not be TCP based, but it is quite often the case. The term socket is also often used to refer to the API provided by the operating system that allows you to make a connection over the TCP/IP stack, for example, the Winsock API provides an API for connections over the TCP/IP stack on Windows.

套接字是唯一映射到应用程序的,因为端口是由操作系统为您管理的.

A socket is mapped uniquely to an application as the ports are managed for you by the operating system.

进一步阅读: http://en.wikipedia.org/wiki/Internet_socket 查看全文

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