HTTP-stream done

This commit is contained in:
serverericoza 2010-06-06 21:40:23 +02:00
parent 15a5eb42fe
commit ff6f3d6f57
2 changed files with 12 additions and 7 deletions

View file

@ -6,12 +6,14 @@
int main() {
SWUnixSocket mySocket;
mySocket.connect("../socketfile");
std::string msg;
mySocket.connect("/tmp/socketfile");
char buffer[500000];
int msg;
// do something with mySocket...
std::cout << "HTTP/1.1 200 OK\nConnection: close\nContent-Type: video/x-flv\n\n";
while(true) {
msg = mySocket.recvmsg();
std::cout << msg;
msg = mySocket.recv(&buffer[0],10000);
std::cout.write(buffer,msg);
}
// disconnect
mySocket.disconnect();

View file

@ -27,11 +27,11 @@ int main() {
int position_startframe = 0;
int frame_bodylength = 0;
SWUnixSocket listener;
SWUnixSocket *mySocket;
SWUnixSocket *mySocket = NULL;
SWBaseSocket::SWBaseError BError;
cur_header_pos = fread(&header,1,13,stdin);
listener.bind("../socketfile");
listener.bind("/tmp/socketfile");
listener.listen();
listener.set_timeout(1,0);
@ -42,7 +42,7 @@ int main() {
if (!mySocket) {
mySocket = (SWUnixSocket *)listener.accept(&BError);
if (mySocket) {
mySocket->send(&header[0],cur_header_pos);
mySocket->send(&header[0],13);
}
}
}
@ -63,6 +63,9 @@ int main() {
std::cout << "Total message read!\n";
if (mySocket) {
mySocket->send(&buffer[0], position_current, &BError);
if ( BError != SWBaseSocket::ok ) {
mySocket = 0;
}
}
}