|
-
January 11th, 2010, 05:44 PM
#1
How can i make this multithreaded?
Hi,
I am creating a windows socket application whereby client can connect to the server and the server responds with a series of messages. This is a test application, and i have got it working, but only one client can connect. I want to enable multiple connections. I need to change the code here:-
Code:
#ifndef __TCPSERVER_H
#define __TCPSERVER_H
#include "Sockets.h"
#include <string>
using namespace std;
class TCPServer {
protected:
ListeningSocket *listener;
int backlog;
sockaddr_in server_addr;
size_t localPort;
public:
TCPServer(size_t port, int backLog = 1);
virtual ~TCPServer();
string receive(TCPSocket *connSocket, int len);
bool send(TCPSocket *connSocket, string sent_str);
void processLoop();
virtual bool run(TCPSocket *connSocket,
sockaddr_in *client_addr) = 0;
};
#endif //__TCPSERVER_H
Is there a way i can do this? I think i need to check if the thread is running first and then enable multiple connections but dont really know how to do it.
Hope someone can help..
If you needs the Sockets.h file i will provide this.
Regards
Billy
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|