errno

基于linux或windows平台上的c/s简单通信

血红的双手。 提交于 2019-12-04 11:55:14
linux: tcpclient.cpp 1 #include<iostream> 2 #include<unistd.h> 3 #include<sys/types.h> 4 #include<sys/socket.h> 5 #include<netdb.h> 6 #include<arpa/inet.h> 7 #include<cstring> 8 #include<sstream> 9 10 using namespace std; 11 12 #define BUFSIZE 512 13 14 // #define SERVERIP "192.168.41.32" 15 // #define SERVERPORT 4140 16 17 /*error report*/ 18 static void bail(const char *on_what){ 19 fputs(strerror(errno), stderr); 20 fputs(": ", stderr); 21 fputs(on_what, stderr); 22 fputc('\n', stderr); 23 exit(1); 24 } 25 26 void getarg(int argc,char* argv[],const char** SERVERIP,int* SERVERPORT) 27 { 28

C函数之readlink

六眼飞鱼酱① 提交于 2019-12-04 06:04:08
函数原型; #include<unistd.h> ssize_t readlink(const char *path, char *buf, size_t bufsiz); 函数说明: readlink()会将参数path的符号链接内容存储到参数buf所指的内存空间,返回的内容不是以\000作字符串结尾,但会将字符串的字符数返回,这使得添加\000变得简单。若参数bufsiz小于符号连接的内容长度,过长的内容会被截断,如果 readlink 第一个参数指向一个文件而不是符号链接时,readlink 设 置errno 为 EINVAL 并返回 -1。 readlink()函数组合了open()、read()和close()的所有操作。 path是一个存在的软连接。 返回值: 执行成功则返回字符串的字符数,失败返回-1, 错误代码存于errno。 错误代码: EACCESS 取文件时被拒绝,权限不够 EINVAL 参数bufsiz为负数 EIO O存取错误 ELOOP 欲打开的文件有过多符号连接问题 ENAMETOOLONG 参数path的路径名称太长 ENOENT 参数path所指定的文件不存在 ENOMEM 核心内存不足 ENOTDIR 参数path路径中的目录存在但却非真正的目录 实例: /*** readlink.c ***/ #include<stdio.h>

嵌入式web服务器BOA+CGI+HTML+MySQL项目实战——Linux

[亡魂溺海] 提交于 2019-12-03 20:51:45
准备环境 操作系统: Ubuntu12.04 LTS 环境搭建: 需要 BOA,Apache,CCGI,MySQL,GCC [ Linux下嵌入式Web服务器BOA和CGI编程开发 ] [ 数据库的相关知识——学习笔记 ] 的三 [ mysql中文乱码问题解决 / C程序插入仍是乱码解决 / 卸载重装教学 ] 扩展: 我还用了[ bootstrap ]框架,CSS/JS 源码链接:GitHub:[ 传送门 ] , 码云:[ 传送门 ] 使用方法 环境准备好后,我们在 /var/www 下写HTML文件 在 /var/www/cgi-bin 下写c文件,编译后命名为.cgi。 编译命令仅供参考 gcc -o login.cgi login.c cgic.c -lpthread -ldl -lmysqlclient 程序都写好后,我们开始测试。 1、开启MySQL服务 默认开启 我的程序需要事先 新建用户test,数据库register,表user mysql -utest -ptest // 创建新用户test mysql> create user 'test'@'localhost' identified by 'test'; // 给test用户所有权限 mysql> grant all privileges on *.* to test@localhost identified

Should I use system_category or generic_category for errno on Unix?

孤街醉人 提交于 2019-12-03 15:25:45
C++0x has two predefined error_category objects: generic_category() and system_category() . From what I have understood so far, system_category() should be used for errors returned by the operating system, and generic_category() should be used for the generic values found in std::errc , which correspond to errno values. However, what should be done on Unix-like systems, where errno values are the errors returned by the operating system? Should I use system_category() (which would be wrong on non-Unix-like systems, needing an #ifdef ), or should I use generic_category() (which would be wrong on

What kind of errors set “errno” to non-zero? Why does fopen() set “errno” while fputc() does not?

こ雲淡風輕ζ 提交于 2019-12-03 14:36:05
What kind of errors faced by what kind of library functions affect the errno and set it to non-zero value? In my following program, I intended to use if(errno!=0) as a condition to check if the library functions I used functioned properly or not, and this is what I found (see the code below): First I used if(errno!=0) to test if a file has been opened successfully with fopen() or not. If I try to open a non-existent file, then errno is set to non-zero (2 in my case) and it is verified by printing out the value of errno at each stage. But if I open an existing file, then the value of errno

03-mock数据【data.json】

大城市里の小女人 提交于 2019-12-03 13:29:21
1、前后端分离式开发,约定好数据字段接口! 2、前端mock静态数据,开发完毕后,与后端进行数据联调! 3、vue.config.js 配置 devServer 1 const appData = require('./data.json') 2 const seller = appData.seller 3 const goods = appData.goods 4 const ratings = appData.ratings 5 module.exports = { 6 css: { 7 loaderOptions: { 8 stylus: { 9 'resolve url': true, 10 'import': [ 11 './src/theme' 12 ] 13 } 14 } 15 }, 16 pluginOptions: { 17 'cube-ui': { 18 postCompile: true, 19 theme: true 20 } 21 }, 22 devServer: { 23 before(app) { 24 app.get('/api/seller',function(req, res) { 25 res.json({ 26 errno:0, 27 success:200, 28 data:seller 29 }) 30 }) 31 app.get('

Where can I see the list of functions that interact with errno?

喜你入骨 提交于 2019-12-03 12:44:02
In the book "The C Programming Language" it says: "Many of the functions in the library set status indicators when error or end of file occur. These indicators may be set and tested explicitly. In addition, the integer expression errno (declared in <errno.h> ) may contain an error number that gives further information about the most recent error." Where can I see a list of these functions? The standard says this about errno : The value of errno is zero at program startup, but is never set to zero by any library function. The value of errno may be set to nonzero by a library function call

Getting IOError: [Errno Invalid number of channels] -9998 when using mic with PyAudio on Raspberry Pi

匿名 (未验证) 提交于 2019-12-03 10:24:21
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Bad news, everyone! I try to use a microphone on my Raspberry Pi through PyAudio but without success. The microphone is connected to a USB sound card. The microphone works when I go through 'arecord' : pi@raspberrypi ~ $ arecord -D plughw:0,0 -f cd test2.wav Recording WAVE 'test2.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo However, when I do the test record.py in PyAudio, I got an error. The error is the same for all programs in Python that uses PyAudio : pi@raspberrypi /usr/src/pyaudio/test $ python record.py ALSA lib pcm.c

IOError: [Errno 2] No such file or directory trying to open a file

匿名 (未验证) 提交于 2019-12-03 09:05:37
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am very new to Python so please forgive the following basic code and problem, but I have been trying to figure out what is causing the error I am getting (I have even looked at similar threads on S.O.) but can't get past my issue. Here is what I am trying to do: loop through a folder of CSV files search for a 'keyword' and delete all lines containing the 'keyword' save output to a separate folder Here is my code: import os, fnmatch import shutil src_dir = "C:/temp/CSV" target_dir = "C:/temp/output2" keyword = "KEYWORD" for f in os.listdir

Getting “Errno::ENOENT: No such file or directory @ rb_sysopen” while reading the CSV file from the AWS S3

匿名 (未验证) 提交于 2019-12-03 09:02:45
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have application which is deployed to Heroku. I have added functionality for uploading users thorough the CSV. For this I have provided CSV upload functionality (Used Paperclip gem). Here is my code for reading the file and creating new user def import(file) CSV.foreach(file.path, headers: true) do |row| row_hash = row.to_hash.values data = row_hash[0].split("\t") . . . end On the local it is working fine. But on the heroku it is giving me following error Errno::ENOENT: No such file or directory @ rb_sysopen - https://s3.amazonaws.com/....