Error Compiling a chat server app with SC

im working on a command line chatting app i

am done for now but my only problem is that i cant compile my project

so plzz if any one can help i appreciate it

my program is Microsoft Visual Studio 2010

the code of the main .cpp is:

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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
#include <iostream>
#include <chat_server.h>


CChatServer CServerObj;


UINT  ServerRecThread(LPVOID pParam)
{	
	SOCKET sRecSocket = (SOCKET)pParam;
	while(1)
	{
		if(CServerObj.RecClient(sRecSocket))
			break;
	}
	return 0;
}



UINT  ServerListenThread(LPVOID pParam)
{	

	while(1)
		CServerObj.StartListenClient();
	return 0;
}



CChatServer::CChatServer()
{
    cout << "Starting up TCP Chat server\n";
	m_bIsConnected = false;

    WSADATA wsaData;

    sockaddr_in local;

    int wsaret=WSAStartup(0x101,&wsaData);

    if(wsaret!=0)
    {
        return;
    }

    local.sin_family=AF_INET; 
    local.sin_addr.s_addr=INADDR_ANY; 
    local.sin_port=htons((u_short)8084); 

    m_SListenClient=socket(AF_INET,SOCK_STREAM,0);


    if(m_SListenClient==INVALID_SOCKET)
    {
        return;
    }


    if(bind(m_SListenClient,(sockaddr*)&local,sizeof(local))!=0)
    {
        return;
    }


    if(listen(m_SListenClient,10)!=0)
    {
        return;
    }

	m_bIsConnected = true;
    return;
}

CChatServer::~CChatServer()
{
    closesocket(m_SListenClient);

    WSACleanup();
}

void CChatServer::StartListenClient()
{

    sockaddr_in from;
    int fromlen=sizeof(from);

    m_SClient=accept(m_SListenClient,
         (struct sockaddr*)&from,&fromlen);

	if(m_SClient != INVALID_SOCKET)
		m_vClientList.push_back(m_SClient);

	AfxBeginThread(ServerRecThread,(void *)m_SClient);

}



int CChatServer::SendMessagePort(string sMessage)
{
		int iStat = 0;
		list<SOCKET>::iterator itl;

		if(m_vClientList.size() == 0)
			return 0;

		for(itl = m_vClientList.begin();itl != m_vClientList.end();itl++)
		{
			iStat = send(*itl,sMessage.c_str(),sMessage.size()+1,0);			
			if(iStat == -1)
				m_vClientList.remove(*itl);
		}

		if(iStat == -1)
			return 1;

		return 0;

}

int CChatServer::RecClient(SOCKET sRecSocket)
{
    char temp[4096];
	int iStat;
		
    //cout <<inet_ntoa(from.sin_addr) <<":"<<temp<<"\r\n";
		iStat = recv(sRecSocket,temp,4096,0);
		if(iStat == -1)
		{
			m_vClientList.remove(sRecSocket);
			return 1;
		}
		else
		{
			cout <<"\t :>>"<<temp<<"\n";
			SendMessagePort(temp);
			return 0;
		}
	return 0;

}




int main(int argc, char* argv[])
{
    int nRetCode = 0;
	char buf[4096];
	
	cout << "This is the CHAT server.\n";
	cout << "Messages from any pc will be broadcasted to all connected pcs.\n";
	cout << "Connect to the server pc port 8084 \n";
    cout << "Press ONLY ENTER to quit.\n";
	cout << "=================================================\n";

	if(!CServerObj.IsConnected())
	{
		cout<<"\nFailed to initialise server socket";
		cout<<"\nThis is boby signing off : Bye";
		getch();
		return 1;
	}
	AfxBeginThread(ServerListenThread,0);


	while(gets(buf))
	{
		if(strlen(buf) == 0)
			break;
		if(CServerObj.SendMessagePort(buf))
		{
			cout<<"Problem in connecting to server. Check whether server is running\n";
			break;
		}
	}

	cout<<"\t Signing off.";
	getch();
	
    return nRetCode;
}


and this is the <chat_server.h>
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
#include <Afxwin.h>
#include <stdio.h>
#include <winsock2.h>
#include <conio.h> 
#include<list>
#include <iostream>

using namespace std;

class CChatServer
{
public:
	CChatServer();
	~CChatServer();
	bool IsConnected(){return m_bIsConnected;} // returns connection status
	void StartListenClient(); // Listen to client
	int SendMessagePort(string sMessage); // Send message to sll clients.
	int RecClient(SOCKET sRecSocket); // receive message for a particulat socket
private:
	bool m_bIsConnected; // true - connected false - not connected
	int m_iServerPort;
	list<SOCKET> m_vClientList; // All socket connected to client
	SOCKET m_SClient;
	SOCKET m_SListenClient; // socket listening for client calls
}



i included all the necessary .h files into the Header Files in my project

but it is not running

the Error in the output is :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
1
1>Build started 9/28/2011 12:47:44 AM.
1>InitializeBuildStatus:
1>  Touching "Debug\server_clchat.unsuccessfulbuild".
1>ClCompile:
1>  All outputs are up-to-date.
1>  chat_server.cpp
1>c:\cpp\s_chat\server_clchat\server_clchat\chat_server.cpp(1): warning C4627: '#include <iostream>': skipped when looking for precompiled header use
1>          Add directive to 'StdAfx.h' or rebuild precompiled header
1>c:\cpp\s_chat\server_clchat\server_clchat\chat_server.cpp(3): fatal error C1083: Cannot open include file: 'chat_server.h': No such file or directory
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:00.23
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


any bodyZ help is more than welcome thnx any wayz

this part is the server part of the program and

feel free to copy it or develop it and if u want to help why not

FYI: i added the <StdAfx.h> but still the same error is coming up
Topic archived. No new replies allowed.