Home > database >  Winxp pb9.0 winsock server program
Winxp pb9.0 winsock server program

Time:09-27

Operating environment: PB9.0 Windows XP


Not to mention in the main window w_main add ole mswinsck controls,

Controls the name winsock_a

1. In the main window w_main open () to add the following script

Winsock_a. Object. The protocol=0
//winsock communications protocol to TCP protocol
Winsock_a. Object. Localport=6000
//the native winsock communications port
Winsock_a. Object. Listen ()
//messagebox (" state - listen ", string (winsock_a. Object. State));
If (winsock_a. Object. The state & lt;> 2) then
St_2. Text="error message: start the application service listening on port 6000 failure [winsock control state is:" + string (winsock_a. Object. State) + "] ".

Close (this)
The else

St_2. Text="hint information: start the application service program listening on port 6000 success"

End the if
//start listening

2. In the main window's close () to add the following script

Winsock_a. Object. The close ()


3. The control dataarrival () to add the following script

W_main. Winsock_a. Object. Getdata (ref getd);

Getd is used to receive the client sends data you

W_main. Winsock_a. Object. Senddata publishes the event (SNDD);

You give the client the data returned SNDD

4. The control connectionrequest () to add the following script

If (winsock_a. Object. The state & lt;> 0) then
Winsock_a. Object. The close ()
End the if

Winsock_a. Object. The accept (requestID);

5. The control sendcomplete () to add the following script (so that we can achieve multi-user connection, but concurrency is bad, after all is first come, first service, when the query of concurrency is not high should be able to run under the condition of good)

W_main. Winsock_a. Object. The close ()

Winsock_a. Object. The protocol=0
//winsock communications protocol to TCP protocol
Winsock_a. Object. Localport=6000
//the native winsock communications port
Winsock_a. Object. Listen ()

If (winsock_a. Object. The state & lt;> 2) then
St_2. Text="error message: start the application service listening on port 6000 failure [winsock control state is:" + string (winsock_a. Object. State) + "] ".



Close (w_main);
The else

St_2. Text="hint information: start the application service program listening on port 6000 success"

End the if
//start listening


Description:
1. Registered in Windows environment mswinsck. Ocx control method

First find the WINSOCK DLL, MSWINSCK. OCX files, three copies to Windows \ system32 directory, and change the registry, add the following data items

[HKEY_CLASSES_ROOT \ Licenses \ 2 c49f800 cf - 9 ad6 - c2dd - 11-0080 c7e7b78d]
@="mlrljgrlhltlngjlthrligklpkrhllglqlrk"

Data item: 2 c49f800 - c2dd cf - 9-11 c7e7b78d ad6-0080
Value: mlrljgrlhltlngjlthrligklpkrhllglqlrk

2. Verify the server program methods:

A, use Telnet IP PORT way under the Windows CMD effect is bad, can only enter A character connection is broken,
B, with Unix Telnet IP PORT carriage return after the server program will enter for the client also as input character processing,
C, or the sock with client application sends data can achieve ideal result,

CodePudding user response:

Top!!!!!!

CodePudding user response:

Support experience sharing

CodePudding user response:

To study the ~

CodePudding user response:

Thanks for sharing

CodePudding user response:

Good is good, but can't support variable number of client connections,

CodePudding user response:

As long as your concurrent initiated isn't a second at the same time, should be no problem,

CodePudding user response:

reference 5 floor renziyang reply:
good is good, but can't support variable number of client connections,


LZ adjust code, concurrency is certainly can,,,

CodePudding user response:

Excuse me, how can achieve the result of concurrent?

CodePudding user response:

Ha ha, I also want to know this information

CodePudding user response:

Well, learn

CodePudding user response:

How to manage multiple client connections?

CodePudding user response:

Can also be written, it is so much user connection has a problem, can't deal with the issue of multiple users
  • Related