成功建立完一个socket连接后,就在内存里开了一块空间,然后双方把数据全都放这里面,对方在到这去取,这样理解对吗?哪位详细讲讲或给个链接!
解决方案 »
- 如何将一个listbox的内容复制在另外一个对话框中的listbox现实?
- CMetaFileDC与CDC
- WaitForSingleObject如何等待一个线程的句柄?
- 急!在线等高手帮忙!!!!!!
- 在debug和release下面都很正常的程序,用installshield打包,安装后运行,在特定情况下会出现Runtime error,咋搞?
- vc如何动态生成dll
- 在.net中的ATL工程中如何添加自定义的数据类型?
- 如何使在一个对话框窗口中的控件对齐窗口底部,当窗口的大小改变使其与窗口底部相对位置不变?
- 简单问题!
- 如何给Microsoft DataGrid控件添加属性列?
- 可能是数据表锁的问题,请帮忙
- [VC新手系列] 关于工具条
Sockets are a concept developed at the University of California at Berkeley to add network communication support to the UNIX operating system. The API developed there is now known as the "Berkeley socket interface." Sockets and TCP/IP:
Sockets are generally, but not exclusively, used in conjunction with the Transmission Control Protocol/Internet Protocol (TCP/IP) that dominates Internet communications. The Internet Protocol (IP) part of TCP/IP involves packaging data into "datagrams" that contain header information to identify the source and destination of the data. The Transmission Control Protocol (TCP) provides a means of reliable transport and error checking for the IP datagrams. Within TCP/IP, a communication endpoint is defined by an IP address and a port number. The IP address consists of 4 bytes that identify a server on the Internet. The IP address is generally shown in "dotted quad" format, with decimal numbers separated by periods, for example "209.86.105.231". A port number identifies a particular service or process that the server provides. Some of these port numbers are standardized to provide well-known services. When a socket is used with TCP/IP, a socket is the TCP/IP communication endpoint. Thus, the socket specifies an IP address and a port number.
我的理解:
socket 就相当于 IPADDR:PORT 的标示或句柄,无论TCP还是UDP也好。
一个socket对象,其实就是一个句柄,它本身不负责或包含内存分配,收发数据等。
它更像联结TCP/IP协议栈或应用层的桥梁或入口点。至于你说的“内存里开了一块空间”,那时TCP/IP协议栈程序起的作用。
具体可看STEVENS的《TCP/IP详解》
至于底层每个套接字在创建的时候旧分配了一块内存每一次都是
发送的先将自己的数据放入自己的Socket指定内存
由TCP或者UDP层分包传递过来
接受方的TCP层将接受到的数据包根据标识重新组装放如自己的Socket指定内存中
供接收程序使用以次往复带外数据也一样因为Windows没有真正的带外数据