成功建立完一个socket连接后,就在内存里开了一块空间,然后双方把数据全都放这里面,对方在到这去取,这样理解对吗?哪位详细讲讲或给个链接!

解决方案 »

  1.   

    This morning someone asked about this, I give him the following information(In fact it's from a book, I forward it for you):Windows Sockets:
    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. 
      

  2.   

    wdllove (为什么会这样) ,有点含糊。
    我的理解:
    socket 就相当于 IPADDR:PORT 的标示或句柄,无论TCP还是UDP也好。
    一个socket对象,其实就是一个句柄,它本身不负责或包含内存分配,收发数据等。
    它更像联结TCP/IP协议栈或应用层的桥梁或入口点。至于你说的“内存里开了一块空间”,那时TCP/IP协议栈程序起的作用。
    具体可看STEVENS的《TCP/IP详解》
      

  3.   

    Socket是一个长整形的变量描述一个套接字
    至于底层每个套接字在创建的时候旧分配了一块内存每一次都是
    发送的先将自己的数据放入自己的Socket指定内存
    由TCP或者UDP层分包传递过来
    接受方的TCP层将接受到的数据包根据标识重新组装放如自己的Socket指定内存中
    供接收程序使用以次往复带外数据也一样因为Windows没有真正的带外数据
      

  4.   

    那我一个程序用到了socket,在管理器里看到它的内存是不是也包括了它socket的产生的内存?