Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

oh i was somehow assuming, that you were writing a little webserver-program in c++ on your own, that's where the sockets (sock) come in. http://beej.us/guide/bgnet/ has some nice hints on that. the general flow:

  1. create a (master) socket
  2. bind it to a port
  3. listen on that port

    1. accept returns a client socket for each connection
    2. read / write on that client socket
int outlen = img.width * img.height * img.nChannels;  // bytecount
char head[512];  // make space for the header

sprintf(head,"--mjpegstream\r\nContent-Type: image/jpeg\r\nContent-Length: %lu\r\n\r\n",outlen);
write(sock,head,strlen(head));
write(sock,(char*)(&outbuf[0]),outlen);