我正试图想出最佳办法,把录像文件发送到TCP的袖珍片上。 我已经做了一个标准袖珍方案,但在<条码>上代码>之后。 我的指挥并不确定我如何能够拯救它。
守则样本
//bind server socketfd
if (bind(sfdServer, (struct sockaddr*)&adrServer, ServerAddrLen) < 0)
error("ERROR binding");
listen(sfdServer, 5);
while(1){
printf("Waiting for connections...
");
sfdClient = accept(sfdServer, (struct sockaddr*)&adrClient, &ClientAddrLen);
if(sfdClient < 0)
error("ERROR accepting");
printf("Connection Established.
");
//set buffer to zero
bzero(buff, 2048);
printf("Reading from client.
");
numChar = read(sfdClient, buff, 2048);
//What should go here?
close(sfdClient);
close(sfdServer);
}
Would I just save the buffer as a file movie.mp4 or something like that? I realize I may need to change my buffer size or possibly send it in chunks. But I can t find any good info on the best way to do this. Any help or a point in the right direction would be appreciated!