Problem with send function

Hello, recently I've been getting into the more complicated side of Windows Programming, and I am trying to make a TCP server. I can successfully create and connect to the server, however I'm having trouble sending data from the server to the client. I want to send a message to a client as soon as it connects. Here is my accept function:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
int server::acceptConn()
{
	//wait for incoming connections
	int clientSize = sizeof(clientHint);
	client = accept(listener, (sockaddr *)&clientHint, &clientSize);
	if (client == INVALID_SOCKET)
	{
		return error("Could not create client socket");
	}
	char host[NI_MAXHOST];
	inet_ntop(AF_INET, &clientHint.sin_addr, host, NI_MAXHOST);
	std::cout << host << " connected on port " << 
        ntohs(clientHint.sin_port) << "\n";
	char buf[] = "You are connected to the server";
        //the below line is my problem
	send(client, buf, sizeof(buf), 0);
	return 0;
}


any possible help would be greatly appreciated!
Last edited on
What's the problem? I mean, how do you know it's not working?

Is the client doing a recv when it connects?

Why isn't client a local variable?
I'm using PuTTY as the client. When I connect, the console just stays blank. "client" is defined as a socket in the header file.
Nevermind, it turns out that the problem was with PuTTY! I created my own c++ client and it worked fine!
putty has worked great for around 30 years or more. I suspect it is not the problem, possibly a configuration issue. If you decide you need it to work (being one of the most popular terminal programs out there) its probably something very simple to fix. If not, no harm done.
Topic archived. No new replies allowed.