易截截图软件、单文件、免安装、纯绿色、仅160KB

linux下tcp服务器源码示例

#include <errno.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdlib.h>
#include <string.h>
#include <netinet/in.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
struct _NSS_HEADER
{
unsigned short ProtocolVersion; /* 协议版本信息 */
unsigned short MsgType; /* 消息类型 */
unsigned short TransactionNo; /* 传输编号 */
unsigned short PacketLength; /* 数据包长度,包括Header */
}NSS_HEADER;
void str_echo(int sockfd)
{
ssize_t readLen;
ssize_t writeLen;
char buf[8];
while ( true )
{
readLen = read(sockfd, buf, 8);
if (readLen < 0 && errno == EINTR)
{
continue;
}
else if ( readLen <= 0 )
{
perror( "read:");
return ;
}
printf( "recv data successed. data len: %d\n", readLen );
int nWriteLen = 0;
while ( true )
{
writeLen == write(sockfd, &buf[nWriteLen], readLen-nWriteLen);
if (writeLen < 0 && errno == EINTR)
{
continue;
}
else if ( writeLen < 0 )
{
perror ( "write:" );
return;
}
nWriteLen += writeLen;
// 已写完,直接返回
if (nWriteLen >= readLen )
{
break;
}
}
printf( "send data successed. data len: %d\n", readLen );
}
}
int main(int argc, char **argv)
{
printf( "server ip: %s\n", argv[1] );
printf( "server port: %s\n", argv[2] );
printf( "\nservice starting ... \n\n" );
int listenfd, connfd;
pid_t childpid;
socklen_t clilen;
struct sockadd


相关文档:

Linux的第一个进程:init(1)


引自:http://server.it168.com/a2009/0309/267/000000267918.shtml
4.1.7 Linux的第一个进程:init(1)
init是Linux系统执行的第一个进程,进程ID为1,是系统所有进程的起点,主要用来执行一些开机初始化脚本和监视进程。Linux系统在完成内核引导以后就开始运行init程序,init程序需要读取配置文件/etc/inittab。init ......

实用技巧:Linux系统下文件权限设置方法

  Windows系统其实和Linux系统有相似的地方,Windows系统文件、目录的属性有只读、隐藏,而Linux也一样。 Linux中,每一个文件都具有特定的属性。主要包括文件类型和文件权限两个方面。可以分为5种不同的类型:普通文件、目录文件、链接文件、设备文件和管道文件。 所谓的文件权限,是指对文件的访问权限,包括对 ......

Linux 下 将PDF文件中的文本,图片导出的方法。


PDF格式文件中的文本是可以导出来再修改的。
同样,PDF里面的插图也是可以提取出来的。
PDF转纯文本:
pdftotext -enc GBK godson2e-data.Sheet.pdf text.GBK.txt
-enc (encoding)
要参照/etc/xpdf/xpdfrc 里面提到的编码格式。对于中文,用GBK
就可以了。
提取插图:
pdfimages godson2e-data.Sheet.pdf img
该 ......

Linux查看文件夹大小的命令

[root@ns1 opt]#  du -h -s /* | sort
12K     /mnt
13M     /sbin
16K     /lost+found
1.8G    /usr
194M    /root
22G     /opt
24K     /tmp
4.0K&n ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号