本文整理汇总了C++中sendFile函数的典型用法代码示例。如果您正苦于以下问题:C++ sendFile函数的具体用法?C++ sendFile怎么用?C++ sendFile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sendFile函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: connectToServer
void connectToServer(char * serveraddress, char * port, char* transType, char * infile){
// SSL init
SSL_library_init();
// ============== SSL init //
// establish connection
BIO* bio = establishSSLConnection(serveraddress, port);
// ================ STEP 1 FINISHED ESTABLISHED AN SSL CONNECTION
// Verify client
performRSAChallenge(serveraddress, port, bio);
// ================
int transaction = verifyTransaction(serveraddress, port, transType, bio);
if(transaction == 1) //send
{
sendFile(serveraddress, port, infile, bio);
}
if(transaction == 2) //recieve
{
recieveFile(serveraddress, port, infile, bio);
}
if(transaction < 0) //error
{
printf("Something went wrong with determining transaction type.");
}
if(transaction < 0) //error
{
printf("Something went wrong with determining transaction type.");
}
printf("SSL Connection closed.\n");
BIO_free(bio);
}
开发者ID:Martin-Ting,项目名称:Encrypted-file-server-OpenSSL,代码行数:31,代码来源:client.c
示例2: selectFile
void selectFile(char *filename)
{
int filesize;
char path[1024];
FILE *file;
if(filename == NULL)
return;
sprintf(path, "/ESIEACloud/%s/%s", actualSession->login, filename);
fprintf(stderr, "path: %s\n", path);
file = fopen(path, "r");
if(file == NULL)
fprintf(stderr, "Ah bah le fichier ne s'ouvre pas\n");
fseek(file, 0L, SEEK_END);
filesize = ftell(file);
fseek(file, 0L, SEEK_SET);
if(file == NULL)
sprintf(actualSession->header, "Content-Type: text/html\r\n\r\nFile Not Found");
else
sprintf(actualSession->header, "Content-Description: File Transfer\r\n"
"Content-Type: application/octet-stream\r\n"
"Content-Disposition: attachment; filename=%s\r\n"
"Content-Transfer-Encoding: binary\r\n"
"Expires: 0\r\n"
"Cache-Control: must-revalidate, post-check=0, pre-check=0\r\n"
"Pragma: public\r\nContent-Length: %d\r\n"
"\r\n", filename, filesize
);
sendHeader();
sendFile(file);
}
开发者ID:TKV14,项目名称:ESIEACloud,代码行数:35,代码来源:page.c
示例3: setupUi
OneToOneRoom::OneToOneRoom(avc::ChatClient* client, const std::wstring& remote)
{
remote_ = remote;
client_ = client;
setupUi(this);
userInfoWidget->show();
rightLayout->addWidget(new QSizeGrip(this), 0, Qt::AlignBottom | Qt::AlignRight);
textBrowser->setFrameStyle(QFrame::NoFrame);
textEdit->setFrameStyle(QFrame::NoFrame);
QFile file(":/Resources/scrollbar.qss");
file.open(QFile::ReadOnly | QFile::Text);
QTextStream in(&file);
QString content = in.readAll();
textBrowser->verticalScrollBar()->setStyleSheet(content);
textEdit->verticalScrollBar()->setStyleSheet(content);
addPicBtn->setIcon(QIcon(":/Resources/image.png"));
addVoiceBtn->setIcon(QIcon(":/Resources/voice.png"));
sendFileBtn->setIcon(QIcon(":/Resources/file.png"));
titleBar->setTitle(QString("%[email protected] chat room").arg(QString::fromStdWString(client_->getEmail())));
textEdit->setFocus();
titleBar->setTitle(QString("%1->%2").arg(QString::fromStdWString(client_->getEmail()), QString::fromStdWString(remote_)));
new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_T), this, SLOT(test()));
connect(pushButton, SIGNAL(clicked()), this, SLOT(onSendClicked()));
connect(addPicBtn, SIGNAL(clicked()), this, SLOT(onAddPicClicked()));
connect(sendFileBtn, SIGNAL(clicked()), this, SLOT(sendFile()));
//connect(stackedWidget, SIGNAL(currentChanged(int)), this, SLOT(stackedWidgetCurrentChanged(int)));
}
开发者ID:Jichao,项目名称:avchat,代码行数:31,代码来源:OneToOneRoom.cpp
示例4: put
void put(){
strcpy(filename, command.arguments);
fprintf(stdout, "put() : %s\n", filename);
// check if the file exists //
FILE *file_ptr = fopen(filename, "r");
if(!file_ptr){
fprintf(stderr, "The specified does not exist\n");
return;
}
// Send command //
send_pack(PUT, command.arguments, sock);
fprintf(stdout, "%s\n", packet_str);
/* send port number for data connection to server */
send_data_port();
// make socket and accept server's Data Connection (active)//
makeDataConnection();
fprintf(stderr, "put() : data connection accepted\n");
// send file //
sendFile(file_ptr);
fprintf(stdout, "put() : complete file sent\n");
fflush(stdout);
//close the file
fclose(file_ptr);
// close the data connection //
close(request->serverSocket);
}
开发者ID:pranavgupta21,项目名称:multithreaded-FTP-client-server,代码行数:34,代码来源:client_func.c
示例5: QMainWindow
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
curDate_ = QDate::currentDate();
ui->btCurDate->setText("Today\n"+curDate_.toString());
selDate_ = curDate_;
ui->lSelDate->setText(selDate_.toString());
fillYearTable(*ui->twYear);
fillMonthTable(*ui->twMonth);
fillDayTable(*ui->twDay, curDate_.daysInMonth());
fillTaskField();
standartStuffForAllTables(*ui->twTaskField);
fillHangedTaskField();
standartStuffForAllTables(*ui->twHangedTaskField);
timer_ = new QTimer(this);
connect(timer_, SIGNAL(timeout()), this, SLOT(sendFile()));
timer_->start(PERIOD);
}
开发者ID:Wargy,项目名称:IzzyTime,代码行数:25,代码来源:mainwindow.cpp
示例6: resetProgress
void MainWindow::begin()
{
//receiveList("Starting File Send.");
resetProgress();
int ret = QMessageBox::No;
if((ui->lcdWorkNumberX->value()!=0)||(ui->lcdWorkNumberY->value()!=0)||(ui->lcdWorkNumberZ->value()!=0))
{
QMessageBox msgBox;
msgBox.setText("Wish to \"zero position\" before beginning?");
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel);
msgBox.setDefaultButton(QMessageBox::Yes);
ret = msgBox.exec();
if(ret ==QMessageBox::Yes)
setHome();
}
if(ret!=QMessageBox::Cancel)
{
ui->tabAxisVisualizer->setEnabled(false);
ui->groupBoxManualGCode->setEnabled(false);
ui->Begin->setEnabled(false);
ui->Stop->setEnabled(true);
ui->progressFileSend->setEnabled(true);
ui->outputRuntime->setEnabled(true);
ui->labelRuntime->setEnabled(true);
ui->openFile->setEnabled(false);
ui->btnGRBL->setEnabled(false);
ui->btnUnlockGrbl->setEnabled(false);
ui->btnSetHome->setEnabled(false);
ui->btnGoHomeSafe->setEnabled(false);
emit sendFile(ui->filePath->text());
}
}
开发者ID:kosme,项目名称:GrblHoming,代码行数:32,代码来源:mainwindow.cpp
示例7: sendFile
void ClientWindow::on_sendFileButton_clicked() {
// Request a file to the user and emit a signal with the path to this file
emit sendFile(QFileDialog::getOpenFileName(0, "Send a file", QString(), "All (*)"));
// Focus the message editing box
message->setFocus();
}
开发者ID:Moutarde,项目名称:3DWebcam,代码行数:7,代码来源:ClientWindow.cpp
示例8: staticHandler
void staticHandler(struct headers *request, int sockfd){
char filePath[MAX_URI_SIZE] = DOC_ROOT;
char *uri = getHeader(request, "URI:");
strcat(filePath, uri);
struct responseHeaders headers = {200, "OK", LOCATION, "text/html", "UTF-8", 0, false}; //defaults
FILE *f = NULL;
if(access(filePath, F_OK) != 0){
headers.code = 404;
headers.codeName = "Not Found";
strcpy(filePath, "./not_found");
}else if(access(filePath, R_OK) != 0){
headers.code = 403;
headers.codeName = "Forbidden";
strcpy(filePath, "./forbidden");
}else if(strcmp(uri, "/") == 0){
f = popen("/bin/ls", "r");
FILE *p = popen("ls | wc -c", "r"); //another pipe for finding size
fscanf(p, "%d", &headers.fileSize);
pclose(p);
}
if(f == NULL){
f = fopen(filePath, "r");
fseek(f, 0, SEEK_END);
headers.fileSize = ftell(f);
fseek(f, 0, SEEK_SET);
}
sendHeaders(headers, sockfd);
sendFile(f, sockfd);
}
开发者ID:Paul92,项目名称:HTTPServer,代码行数:34,代码来源:static.c
示例9: printf
void Server::waitForClient()
{
printf("Waiting for client.\n");
serialReceive(msgBuffer); // Recieve filename from client.
FILE* stream;
if(stream = fopen(msgBuffer, "r")) // If opening a file with the name recieved is succesfull continue
{
long lengthOfFile = getFileLength(stream); // Get file length of opened file in bytes.
printf("User requested: %s with a size of %ld bytes\n", msgBuffer, lengthOfFile); // Print out filename and lenght of file.
sprintf(msgBuffer, "%ld", lengthOfFile); // Convert lenght of file to string.
serialSend(msgBuffer, strlen(msgBuffer)+1); // Send lenght of file
sendFile(stream, lengthOfFile); // Use function to send file, giving pointer and lenght of the file to send.
fclose(stream); // Close file.
}
else // If file couldnt be found, print out message and send to client 0 filelenght (its not found).
{
printf("Client tried to get: %s\n", msgBuffer);
serialSend("0", 2);
}
printf("Client connection closed\n");
}
开发者ID:Salizer,项目名称:TCPFileSharing,代码行数:32,代码来源:Server.cpp
示例10: file
void ChatForm::onAttachClicked()
{
QStringList paths = QFileDialog::getOpenFileNames(0,tr("Send a file"));
if (paths.isEmpty())
return;
for (QString path : paths)
{
QFile file(path);
if (!file.exists() || !file.open(QIODevice::ReadOnly))
{
QMessageBox::warning(this, tr("File not read"), tr("qTox wasn't able to open %1").arg(QFileInfo(path).fileName()));
continue;
}
if (file.isSequential())
{
QMessageBox::critical(0, tr("Bad Idea"), tr("You're trying to send a special (sequential) file, that's not going to work!"));
file.close();
continue;
}
long long filesize = file.size();
file.close();
QFileInfo fi(path);
emit sendFile(f->getFriendID(), fi.fileName(), path, filesize);
}
}
开发者ID:stqism,项目名称:qTox,代码行数:27,代码来源:chatform.cpp
示例11: QString
void ChatForm::onScreenshotTaken(const QPixmap &pixmap) {
// use ~ISO 8601 for screenshot timestamp, considering FS limitations
// https://en.wikipedia.org/wiki/ISO_8601
// Windows has to be supported, thus filename can't have `:` in it :/
// Format should be: `qTox_Screenshot_yyyy-MM-dd HH-mm-ss.zzz.png`
QString filepath = QString("%1screenshots%2qTox_Screenshot_%3.png")
.arg(Settings::getInstance().getSettingsDirPath())
.arg(QDir::separator())
.arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH-mm-ss.zzz"));
QFile file(filepath);
if (!file.open(QFile::ReadWrite))
{
QMessageBox::warning(this,
tr("Failed to open temporary file", "Temporary file for screenshot"),
tr("qTox wasn't able to save the screenshot"));
return;
}
pixmap.save(&file, "PNG");
long long filesize = file.size();
file.close();
QFileInfo fi(file);
emit sendFile(f->getFriendID(), fi.fileName(), fi.filePath(), filesize);
}
开发者ID:TheNain38,项目名称:qTox,代码行数:28,代码来源:chatform.cpp
示例12: sendFolder
void FolderSource::sendFolder(File folder, HTTPDecoder& dec) {
// get all files in this folder
std::vector<File> files;
folder.listFiles(files);
// struct for filesize-status
struct stat fileStats;
// process each file
for (const auto file : files) {
// if this file is another folder -> recursion
if (file.isFolder()) {
// send this subfolder
sendFolder(file, dec);
} else {
// check file-size to skip 0-byte files
stat(file.getAbsolutePath().c_str(), &fileStats);
if (fileStats.st_size == 0) {continue;}
// send one file
sendFile(file, dec);
// check if canceled?
if (!running) {break;}
}
}
}
开发者ID:k-a-z-u,项目名称:NetAnalyzer,代码行数:35,代码来源:FolderSource.cpp
示例13: processHttpMessage
void processHttpMessage(char *httpMessage, int sockClient)
{
printf("funcion processHttpMessage\n");
printf("Full HTTP Message:\n");
logger(httpMessage);
char GET[4] = "GET\0";
char *method = substring(httpMessage, 0, 3);
logger("Method: ");
logger(method);
if(strcmp(method, GET) == 0) {
int i = 0;
while(httpMessage[i] != '\n')
{
i++;
}
char *path = substring(httpMessage, 5, i - 10);
logger(path);
int sockIndexProcess = sendPathToIndexProcess(path);
char *realPath = malloc(8092);
readMessage(sockIndexProcess, realPath);
sendFile(sockClient, realPath);
}
}
开发者ID:andrescabrera,项目名称:TPprogramacionEnRedes,代码行数:26,代码来源:threads.c
示例14: switch
int qSslChat::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QWidget::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
if (_c == QMetaObject::InvokeMetaMethod) {
switch (_id) {
case 0: peerRejectedFileSend(); break;
case 1: fsCompleted(); break;
case 2: hostConnection(); break;
case 3: connectToHost(); break;
case 4: activateMsgSending(); break;
case 5: sendMsg((*reinterpret_cast< QString(*)>(_a[1]))); break;
case 6: receiveMessage((*reinterpret_cast< QString(*)>(_a[1]))); break;
case 7: displayMsg(); break;
case 8: endConnection(); break;
case 9: sendAnticipation(); break;
case 10: sendFile((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break;
case 11: notifyServer(); break;
case 12: completeFileSend(); break;
case 13: selectSmiley(); break;
case 14: insertSmiley((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
case 15: displayCertificateInfo(); break;
}
_id -= 16;
}
return _id;
}
开发者ID:ioannisb,项目名称:Buddies-1.10,代码行数:28,代码来源:moc_qSslChat.cpp
示例15: recv
bool ServerSocket::RecvData(char *buffer, int size)
{
int i = recv(mySocket, buffer, size, 0);
buffer[i] = '\0';
cout << "<<< " << buffer;
// Convert to lower-case to compare
for (int j = 0; j < i; j++)
buffer[j] = tolower(buffer[j]);
// Process commands
if (strncmp(buffer, "list", 4) == 0)
{
// Client wants a dir list!
// We'll just send them the current one
dirList("./");
}
else if (strncmp(buffer, "send", 4) == 0)
{
// Client wants a file!
sendFile(buffer);
}
else if (strncmp(buffer, "quit", 4) == 0)
{
// Client wants us to go away!
done = true;
}
return true;
}
开发者ID:drewmnoel,项目名称:Project2,代码行数:30,代码来源:ServerSocket.cpp
示例16: sendDir
int sendDir(int fd, char * dir_name)
{
DIR *source = NULL;
struct dirent *ent = NULL;
char name[FILENAME_SIZE];
source = opendir(dir_name);
if(source == NULL)
{
perror("Fail to opendir\n");
return 0;
}
while((ent = readdir(source)) != NULL)
{
if((strcmp(ent->d_name,"..") != 0) && (strcmp(ent->d_name, ".") != 0))
{
strcpy(name,"\0");
strcat(name, dir_name);
strcat(name,"/");
strcat(name,ent->d_name);
if(ent->d_type == 4)
sendDir(fd, name);
else if(ent->d_type == 8)
sendFile(fd, name);
}
}
return 0;
}
开发者ID:mjwtom,项目名称:DedupeCluster,代码行数:29,代码来源:client.c
示例17: main
int main(int argc, char *argv[])
{
if (argc < 3)
{ // Check that there is an appropriate amount of arguements for usage
fprintf(stderr,"usage %s plaintextfile keytextfile portno\n", argv[0]);
exit(0);
}
FILE *cipherTextFP,*keyTextFP; // File pointers
/* Open files */
cipherTextFP= fopen(argv[1],"r");
keyTextFP = fopen(argv[2],"r");
/* ERROR out if files don't open */
if(cipherTextFP==NULL)error("ERROR opening plaintext file for input",2);
if(keyTextFP==NULL)error("ERROR opening keytext file for input",2);
/* This if statement checks that the key file is at least as big as the ptext file */
if(fSize(cipherTextFP)>fSize(keyTextFP))error("ERROR cipherText is larger than keyText",2);
/* These if statements employ checkContents to check file for bad chars */
if(checkContents(cipherTextFP))error("ERROR cipherText contains bad char data",2);
if(checkContents(keyTextFP))error("ERROR cipherText contains bad char data",2);
/* Setup socket */
int sockfd = sockSetup(atoi(argv[3]));
/* Authorize server by listening for one time code */
sendAuth(sockfd,"decAck"); // exit if not correct server
/* Transmit key and ptext files */
sendFile(cipherTextFP,sockfd);
sendFile(keyTextFP,sockfd);
/* close open files */
fclose(cipherTextFP);
fclose(keyTextFP);
/* Receive decoded text */
char pText[290000];
receive(pText,sockfd);
close(sockfd);
printf("%s\n", pText);
return (0);
}
开发者ID:reedjosh,项目名称:OTP,代码行数:47,代码来源:otp_dec.c
示例18: handleOrder
void handleOrder(porder po,char* path,int cfd)
{
// printf("path:%s\n",path);
if(ORDER_PWD == po->order)
{
data tbuf;
memset(&tbuf,0,sizeof(tbuf));
recvN(cfd,(char*)&tbuf.len,sizeof(tbuf.len));
recvN(cfd,tbuf.buf,tbuf.len);
printf("%s\n",tbuf.buf);
}
else if(ORDER_LS == po->order)
{
data tbuf;
memset(&tbuf,0,sizeof(tbuf));
recvN(cfd,(char*)&tbuf.len,sizeof(tbuf.len));
recvN(cfd,tbuf.buf,tbuf.len);
printf("%-5s%-20s%-10s\n","type","name","size");
printf("%s\n",tbuf.buf);
}
else if(ORDER_CD == po->order)
{
data tbuf;
memset(&tbuf,0,sizeof(tbuf));
recvN(cfd,(char*)&tbuf.len,sizeof(tbuf.len));
recvN(cfd,tbuf.buf,tbuf.len);
printf("%s\n",tbuf.buf);
}
else if(ORDER_PUTS == po->order)
{
sendFile(cfd,path,po->info);
}
else if(ORDER_GETS == po->order)
{
recvFile(cfd,path,po->info);
}
else if(ORDER_RM == po->order)
{
data tbuf;
memset(&tbuf,0,sizeof(tbuf));
tbuf.len = strlen(po->info);
strcpy(tbuf.buf,po->info);
sendN(cfd,(char*)&tbuf,tbuf.len+sizeof(tbuf.len));
memset(&tbuf,0,sizeof(tbuf));
recvN(cfd,(char*)&tbuf.len,sizeof(tbuf.len));
recvN(cfd,tbuf.buf,tbuf.len);
printf("%s\n",tbuf.buf);
}
else if(ORDER_EXIT == po->order)
{
printf("bye bye!\n");
close(cfd);
exit(0);
}
else
{
printf("command not found\n");
}
}
开发者ID:PrinceClover,项目名称:linux_learn,代码行数:59,代码来源:pp_order.c
示例19: sendFile
void FileTransferManager::chatKeyPressed(QKeyEvent *e, ChatWidget *chatWidget, bool &handled)
{
if (HotKey::shortCut(e, "ShortCuts", "kadu_sendfile"))
{
sendFile(chatWidget->users()->toUserListElements());
handled = true;
}
}
开发者ID:ziemniak,项目名称:kadu,代码行数:8,代码来源:file_transfer_manager.cpp
示例20: WinMain
int APIENTRY WinMain(HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/,
char* lpCmdLine, int /*nCmdShow*/)
{
std::string filename = unquote(lpCmdLine);
std::string snippetUrl = sendFile(filename.c_str());
copyToClipboard(snippetUrl);
return 0;
}
开发者ID:xsnippet,项目名称:explorer-xsnippet,代码行数:8,代码来源:main.cpp
注:本文中的sendFile函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论