Using Winsock to realize voice Full-duplex communication

Source: Internet
Author: User
Tags socket port number

First, the introduction

Windows 95 as a microcomputer operating system, has been fully integrated into the network and communication functions, not only to establish a pure Windows 95 environment, "Peer-to-peer network", but also support a variety of protocols, such as TCP/IP, ipx/spx, NetBUI and so on. In the TCP/IP protocol group, TPC is a connection-oriented coordination, providing users with reliable, Full-duplex byte-throttling services, with validation, flow control, multiplexing and synchronization functions, suitable for data transmission. UDP protocol is connectionless, each packet carries the complete destination address, each grouping is transmitted independently in the system. It can not guarantee the order of grouping, not the recovery and retransmission of group error, so it does not guarantee the reliability of transmission, but it provides high transmission efficiency datagram service, suitable for real-time voice, image transmission, broadcast message and other network transmission.

The Winsock interface provides a new means for interprocess communication, which not only can be used for communication between processes in the same machine, but also support network communication functions. With the introduction of Windows 95. Winsock has been formally integrated into the Windows system and includes 16-bit and 32-bit programming interfaces. And Winsock's development tools can also be found in Borland c++4.0, Visual c++2.0 these C compilers, It consists primarily of a header file named Winsock.h and a dynamic connection library Winsock.dll or Wsodk32.dll, which are used for both Win16 and WIN32 applications respectively.

In this paper, the real-time network communication is realized by UDP protocol for the full duplex transmission of voice. Using the VISUALC++2.0 compilation environment, its dynamic connection library name is Wsock32.dll.

Main points of use of major functions

It is easy to realize Full-duplex network communication by establishing double sockets.

1. Socket build Function:

SOCKET socket(int family,int type,int protocol)
对于UDP协议,写为:
SOCKRET s;
s=socket(AF_INET,SOCK_DGRAM,0);
或s=socket(AF_INET,SOCK_DGRAM,IPPROTO_UDP)

In order to establish two sockets, you must implement a duplicate binding of the address. That is, when a socket is already bound to a local address, in order for another socket to reuse the address, you must set the So_ for that socket by the function setsockopt () before the second socket is bound for the bind () function to be invoked. REUSEADDR socket options. The socket option setting state can be obtained by using the function getsockopt (). Note that the port number for two sockets cannot be the same.

In addition, it involves the setting of socket buffer, according to the stipulation, each zone's set range is: not less than 512 bytes, much larger than 8k bytes, as required, the text selected 4k bytes.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.