HTTP PUT winsock

I have this sending a HTTP PUT, it works great as a one time thing

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
	WSAData wsaData;
	WORD DllVersion = MAKEWORD(2, 1);
	if (WSAStartup(DllVersion, &wsaData) != 0) {
		cout << "Winsock Connection Failed!" << endl;
		exit(1);
	}

	addrLen = sizeof(addr);
	IN_ADDR ipvalue;
	addr.sin_addr.s_addr = inet_addr("127.0.0.1"); 
	addr.sin_port = htons(8282);
	addr.sin_family = AF_INET;

	connection = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
	if (connect(connection, (SOCKADDR*)&addr, addrLen) == 0) {
		string getInput = "PUT /parameter/hd1/spk/volume=0 HTTP/1.1\r\nHost: 127.0.0.1\r\n\r\n";
		send(connection, getInput.c_str(), strlen(getInput.c_str()), 0);
	}


My problem is I want to use a slider to send varying values, something like this
slider2 is externally controlled.

1
2
3
4
5
6
7
8
9
		int intSlider1 = slider2 * 91;
		std::stringstream cmd1;
		cmd1 << "PUT /parameter/hd1/spk/volume=" << intSlider1 << " HTTP/1.1\r\nHost: 127.0.0.1\r\n\r\n";
		string getInput = cmd1.str().c_str();

		if (connect(connection, (SOCKADDR*)&addr, addrLen) == 0) {
			send(connection, getInput.c_str(), strlen(getInput.c_str()), 0);

		}


it sends one request then stops working, I tried repeating this just after it works but the response becomes very laggy
connection = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);


I have a libcul way of doing this it works great in debug, but there are issues with release I can't figure out. Can anybody spot my mistake?
Last edited on
found it I wasn't closing the socket.
closesocket(connection);
Topic archived. No new replies allowed.