ARIX
March 2nd, 2004, 06:11 AM
Hi gurus !!!
I have a simple console app with the following code in it:
#include "stdafx.h"
#include "winsock2.h"
#include "iostream.h"
#include "stdio.h"
int main(int argc, char* argv[])
{
WSADATA wsa;
WSAStartup(1,&wsa);
SOCKET s = socket(AF_INET,SOCK_STREAM,IPPROTO_IP);
SOCKADDR_IN addr;
memset(&addr,0,sizeof(addr));
addr.sin_family = AF_INET;
addr.sin_port = htons(11000);
addr.sin_addr.s_addr = INADDR_ANY;
int res = bind(s,(sockaddr*)&addr, sizeof(sockaddr));
listen(s,3);
int size = sizeof(addr);
printf("Waiting for incoming connection...");
//cout << "Waiting for incoming connection...";
SOCKET sock = accept(s,(sockaddr*)&addr,&size);
return 0;
}
Now the question: Why it's when I use "cout <<" insetad of "printf()", the text appears only after connection accepted ?
Thanks in advance !!!
I have a simple console app with the following code in it:
#include "stdafx.h"
#include "winsock2.h"
#include "iostream.h"
#include "stdio.h"
int main(int argc, char* argv[])
{
WSADATA wsa;
WSAStartup(1,&wsa);
SOCKET s = socket(AF_INET,SOCK_STREAM,IPPROTO_IP);
SOCKADDR_IN addr;
memset(&addr,0,sizeof(addr));
addr.sin_family = AF_INET;
addr.sin_port = htons(11000);
addr.sin_addr.s_addr = INADDR_ANY;
int res = bind(s,(sockaddr*)&addr, sizeof(sockaddr));
listen(s,3);
int size = sizeof(addr);
printf("Waiting for incoming connection...");
//cout << "Waiting for incoming connection...";
SOCKET sock = accept(s,(sockaddr*)&addr,&size);
return 0;
}
Now the question: Why it's when I use "cout <<" insetad of "printf()", the text appears only after connection accepted ?
Thanks in advance !!!