Design, implementation, and introduction of chat programs
Zhou Baofeng
Xi'an Jiaotong University Software College MSE 2002
2005.01
Index
Program design ... 3
2. Program use ... 4
2.1 Use of server ... 5
2.2 Application of the client ... 5
3. References ... 6
Program design
Program design environment:
Using Borland Delphi 7 Enterprise Edition to develop in Windows 2000.
Other design details:
TCP server:
TIDTCPSERVER
Implementation. Used for the interaction of the text.
For each client's TCP connection, start a thread processing. The structural diagram is as follows:
Main thread
Monitor thread
Accept Client 1
Accept Client 1
Accept Client 1
...
Client1.thread
Client2.thread
Client3.Thread
Thread management TidthreadMgrDefault
management.
UDP server:
Tidudpserver in IND
achieve. When a UDP package is received, the UDPREAD event is triggered, and the playback of sound data is performed here.
UDP client:
TidudpClient implementation in Indy. When the collected sound data exceeds the buffer size (2048 bytes), it is called to send the data.
Extraction of sound:
The TACMIN control collects sounds, and the ACMIN control is mainly called the Windows API WaveinOpen function. Function declaration:
Function Waveininken; External MMSYST Name 'WaveinOpen';
(Mmsystem.pas)
Sound encoding:
By default, GSM6.10 encoding, detailed encoding support:
GSM 6.10 8kHz, MONO - Default
11.025kHz, Mono
22.050kHz, Mono
44.100 kHz, Mono
MICORSOFT G.723.1 8 kHz Mono, 6400 Bit / S
8 kHz mono, 5333 bit / s
PCM 8/11/12/16/22/24/32/44/48 KHz, 8/16 / Bit, Mono
MPET Layer -3
56/40/48/32/24/16/8 Kbit / s, 24,000 / 22,000 / 16,000 / 8,000 hz, Stereo
... ..
Sound output:
When the UDP server receives data, use ACMOUT to play.
Adata.read (AudioArray, Adata.size);
IF not audioout.active the begin
With m_playaudioformat.format do begin
WFORMATTAG: = 1;
NChannels: = 1;
NSAMPLESPERSEC: = 22050;
NavgBytespersec: = 22050;
NblockAlign: = 1;
WBITSPERSMPLE: = 8;
Cbsize: = sizeof (tacmwaveformat);
END;
//adioout.open (audioconvertor.formatin);
AudioOut.open (M_PlayAudioformat);
END;
Audioout.play (AudioArray, Adata.size);
2. Program use
Note: Server programs and client programs are not running on the same machine (avoiding sound playback and collection conflicts), one machine can only run a server program or a client program. Server-end log file: charsvr.log client log file: ClientError.log
2.1 Servers
2.2 Application of the client
Select the online user before you can speak.
3. References
[1] INDYIN Depth Atozed Software