Click here to Skip to main content
15,921,622 members

yangzhenping - Professional Profile



Summary

    Blog RSS
60
Authority
6
Debator
1
Enquirer
57
Organiser
403
Participant
0
Author
0
Editor
I am interested in .NET, C#, C/C++, java, php, windows azure, docker, redis, memcached, dotnet-cli, powershell, webrtc, Linux, Android development.

My Chinese blog, check this out: http://blog.csdn.net/yangzhenping

Reputation

Weekly Data. Recent events may not appear immediately. For information on Reputation please see the FAQ.

Privileges

Members need to achieve at least one of the given member levels in the given reputation categories in order to perform a given action. For example, to store personal files in your account area you will need to achieve Platinum level in either the Author or Authority category. The "If Owner" column means that owners of an item automatically have the privilege. The member types column lists member types who gain the privilege regardless of their reputation level.

ActionAuthorAuthorityDebatorEditorEnquirerOrganiserParticipantIf OwnerMember Types
Have no restrictions on voting frequencysilversilversilversilver
Bypass spam checks when posting contentsilversilversilversilversilversilvergoldSubEditor, Mentor, Protector, Editor
Store personal files in your account areaplatinumplatinumSubEditor, Editor
Have live hyperlinks in your profilebronzebronzebronzebronzebronzebronzesilverSubEditor, Protector, Editor
Have the ability to include a biography in your profilebronzebronzebronzebronzebronzebronzesilverSubEditor, Protector, Editor
Edit a Question in Q&AsilversilversilversilverYesSubEditor, Protector, Editor
Edit an Answer in Q&AsilversilversilversilverYesSubEditor, Protector, Editor
Delete a Question in Q&AYesSubEditor, Protector, Editor
Delete an Answer in Q&AYesSubEditor, Protector, Editor
Report an ArticlesilversilversilversilverSubEditor, Mentor, Protector, Editor
Approve/Disapprove a pending ArticlegoldgoldgoldgoldSubEditor, Mentor, Protector, Editor
Edit other members' articlesSubEditor, Protector, Editor
Create an article without requiring moderationplatinumSubEditor, Mentor, Protector, Editor
Approve/Disapprove a pending QuestionProtector
Approve/Disapprove a pending AnswerProtector
Report a forum messagesilversilverbronzeProtector, Editor
Approve/Disapprove a pending Forum MessageProtector
Have the ability to send direct emails to members in the forumsProtector
Create a new tagsilversilversilversilver
Modify a tagsilversilversilversilver

Actions with a green tick can be performed by this member.


 
QuestionWho can correctly answer the following nine questions: [modified] Pin
yangzhenping30-Apr-10 17:27
yangzhenping30-Apr-10 17:27 
AnswerRe: Who can correctly answer the following nine questions: Pin
yangzhenping2-May-10 21:10
yangzhenping2-May-10 21:10 
GeneralAsk the Accept () function in the socket programming Pin
yangzhenping26-Feb-10 7:08
yangzhenping26-Feb-10 7:08 
I use VC + +6.0 write server code, when the listen (listener, 5); opened after listening into the loop
/ /
/ / Infinite loop to accept and deal with new connections
/ /
while (1)
(
/ /
clientAddressLength = sizeof (clientAddress);
newsocket = accept (listener, (struct sockaddr *) & clientAddress, & clientAddressLength);
/ /
...... The following is omitted
)
This approach, under the console no problem, but I wrote that the WIN32 Application, arrived in the implementation of accept (), the server will continue to the connection pool queue query, resulting in the absence of any connection, the phenomenon of the whole process stuck

Is there any way to exclude programs card dead?
(If you can understand why the same infinite loop program is not stuck under the console, while in windowed mode will be choked to death, it would be very grateful to you)
I use the completion port implementation, IOCP, seek expert help to solve the problem loop
Is not a while loop issue is the accept () function itself, an infinite loop check new link
accpet is blocked, one approach is another to open a thread devoted to it
Another approach is to set non-blocking mode

These two approaches are not very much will be

The first is to write I do not do:
unsigned long __stdcall foo (LPVOID param)
(
typedef struct (
HANDLE h;
SOCKET soc;
sockaddr * s;
int * inte;
SOCKET * returnsock;
) fo, * pfo;
pfo f = (fo *) param;
if (f! = NULL)
(
/ / Do ............

f-> returnsock = (SOCKET *) accept (f-> soc, f-> s, f-> inte);
)
delete f; / / here to delete
return 0;
)
SOCKET MyAccept (HWND hWnd, SOCKET sock, sockaddr * sa, int * inter)
(

typedef struct (
HANDLE h;
SOCKET soc;
sockaddr * s;
int * inte;
SOCKET * returnsock;
) fo, * pfo;
pfo f = new fo;
f-> h = hWnd;
f-> soc = sock;
f-> s = sa;
f-> inte = inter;
HANDLE tid = CreateThread (NULL, 0, foo, (LPVOID) f, 0, NULL);
if (! tid)
delete f;
else
:: ResumeThread (tid);
CloseHandle (tid);

SOCKET newsock = (SOCKET) f-> returnsock;
WaitForSingleObject (tid, INFINITE); / / wait for thread end of the
return newsock;
)

/ *
Additional I know of:
Now, I know accpet returns within a certain period of time, you can:
1, set to non-blocking, and then use select to determine isset (listenfd, & readfds).
2, can also be used WSAEventSelect register FD_ACCEPT event, and then set the wait timeout WSAWaitForMultipleEvents * /
GeneralRe: Ask the Accept () function in the socket programming Pin
yangzhenping26-Feb-10 22:26
yangzhenping26-Feb-10 22:26 
GeneralThe first blog in codeproject Pin
yangzhenping1-Feb-10 1:14
yangzhenping1-Feb-10 1:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.