Vista problem

Hello everybody!

I have a BIG error) I wrote a client-server application on winXP using MSVS2005. in my application a used winsock2.h. For trasmiting data I used functions send() and recv(). For GUI I used winAPI. So, Server has a database, Client fill a comboboxes and manth celendar controls to choose parameters. My server I installed on win Server2008 as a service. One client on XP can get information right and without eny errors. When I start this client on Vista - my application closed by OS. It happened, when socket function recv() is waiting while server edit data and send it to him. So, how to avoid closing my programm and why it is happened. here is a code of function of client application, when it is closing:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
pack* sendQuery(int YYYY1,int MM1,int DD1,int hh1,int mm1,int YYYY2,int MM2,int DD2,int hh2,int mm2,char* name,char* subname,int minutes)
{
	pack A; - package of data
	char buf[1024];
	char* str = NULL;
	A.Form2(YYYY1,MM1,DD1,hh1,mm1,
		    YYYY2,MM2,DD2,hh2,mm2,
			name,subname,
			minutes);
	int bytesSent;
	bytesSent = send(m_socket,A.ToString(),A.pack_size,0);//send to server what we want
	int close=0;
	int numeration = 0;
	int lenofpack=0;
	char ttt[10];
	int first=1;
	int length = 0;
	int index  =0 ;
	char* newstr = NULL;
	for(int i=0;i<1024;i++)
		buf[i]=0;
	do
	{
		bytesSent = recv(m_socket,buf,(int)1024,0); //here is stopping
		if(bytesSent>0)
		{
			index = 0;
			int j=0;
			int size = 1024;
			newstr = new char[size];
			for(int i=0;i<size;i++)
				newstr[i] = buf[i];
			while(0<=(index=FindSubString(newstr,size,"okay")))//grabbing a progress markers
			{
				MakesubstringFromString(newstr,size,index,index + (int)strlen("okay"));    
				size = size-(int)strlen("okay");
				j++;
			}
			while(j>0) 
			{
				SendMessage(hwndPB,PBM_STEPIT,0,(LPARAM)0);
				SendMessage(hProgressTitle,WM_SETTEXT,0,(LPARAM)"");
				SendMessage(hProgressTitle,WM_SETTEXT,0,(LPARAM)progressenum[numeration]);  	numeration++;
				j--;
			}
			for(int k=0;k<1024;k++)
				buf[k] =0;
			for(int k=0;k<size;k++)
				buf[k]=newstr[k];
			delete []newstr;
			newstr = NULL;
			if(first==1)
			{
				if(buf[1] == buf[3] && buf[3] == '|')
				{
					int i=0;
					while(buf[i+4]!='|')
					{
						ttt[i] = buf[i+4];
						i++;
					}
					ttt[i]=0;
					lenofpack = atoi(ttt);
					str = new char[lenofpack+10+strlen(ttt)];
					first=0;
				}
			}			
		if(lenofpack>0)//appending bytes in one big buffer
			{
				int i=0;
				while(i<1024)
				{
					str[length+i] = buf[i];
					if(buf[i+1]==0)
					{
						int j=i+1;
						while(j<1024)
						{
							if(buf[j]!=0) break;
							j++;
						}
						if(j==1024)
						{
							
							if(str[length+i]==53 && str[length+i-1]==53 && str[length+i-2]==50 && str[length+i-3]==124) close =1;//"|255| - is the end of the package
							i++;
							break;
						}
					}
					i++;
				}
				str[length+i] = 0;
				length += i;
			}
			for(int k=0;k<1024;k++)
				buf[k] =0;
			if(newstr) {delete []newstr;
			newstr = NULL;}
		}
		else close = 1;
	}while(close<1);
	if(newstr)
	{
		delete []newstr;
		newstr = NULL;
	}
	pack *ret = new pack();
	if(!str) 
	{
		return (pack*)0;
	}	
	if(ret->FillByString(str)) //bytes->package
	{
		if(str)
		{
			delete []str;
			str = NULL;
		}
		return ret;
	}
	if(str) {delete []str;str = NULL;}
	return (pack*)0;
}
close topic. problem sold
Topic archived. No new replies allowed.