Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sometimes console(win) tcp/ip app needs keyboard input to take off

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I have a Visual C++ (Winsock2) application that listens on port 1170. Sometimes it seems to stop whenever a new connection comes in (TCP/IP driver accepts connection fine). It would take off if I press any keyboard key. Weird thing is that app logic does not require any keybord input, no scanf(..) anywhere. This problem only happens under the following conditions.

1- Windows 2000 Professional or Server (SP2)
2- Application puts messages to the standard output or stderr using printf() or fprintf()

code looks like this:

Thread priority is set to THREAD_PRIORITY_HIGHEST

Thread myserver(){

soc = socket(AF_INET,SOCK_STREAM,IPPROTO_IP);
bind(soc;;);
listen(soc,SOMAXCONN);

for(;;){
newsocket = accept(soc,NULL,NULL);

// PROBLEM HAPPENS SOMETIMES ONLY IF NEXT
// STATEMENT IS ENABLED. I MUST have some
// debugging messages.

fprintf(stderr,"New connection!!!\n");

}

} // end of thread myserver

I would appreciate your help very much.

Maurice.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top