linux 网络键盘,鼠标
因为公司的板子上键盘不好按,所以写个网络版的,方便调试。
client .c
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <linux/input.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <netdb.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <sys/socket.h>
int connect_server(char * ipaddr, int myport)
{
int sockfd;
struct hostent *he;
struct sockaddr_in their_addr;
if((he=gethostbyname(ipaddr))==NULL) {
herror("gethostbyname");
return -1;
}
if ((sockfd = socket(PF_INET, SOCK_STREAM, 0)) == -1) {
perror("socket");
return -1;
}
their_addr.sin_family = PF_INET;
their_addr.sin_port = htons(myport);
their_addr.sin_addr = *((struct in_addr *)he->h_addr);
bzero(&(their_addr.sin_zero),0);
if (connect(sockfd, (struct sockaddr *)&their_addr, sizeof(struct sockaddr)) == -1) {
perror("connect");
return -1;
}
return sockfd;
}
int main(void)
{
int fds[16] = {-1};
int fd_max = -1;
char serverip[24] = {0};
int socketfd = -1;
int ret = 0;
struct input_event event_key;
char input[5*1024] = {0};
int fd = open("/proc/bus/input/devices", O_RDWR);
char dev[24] = "/dev/input/";
int len = read(fd, input, 5*1024);
printf("len = %d \n", len);
close(fd);
char *p;
p = input;
int j = 0;
strcpy(serverip, "192.168.168.114");
socketfd = connect_server(serverip, 7838);
if(socketfd == -1)
{
printf("connect_server faild \n");
return -1;
}
struct timeval select_timeout;
fd_set readfds;
select_timeout.tv_sec= 4;
select_timeout.tv_usec = 0;
for(; p != NULL; j++)
{
p = strstr(p, "event");
if (p)
{
memcpy(dev+11, p, 6);
printf("%s\n", dev);
p+= 6;
fds[j] = open(dev, O_RDWR);
相关文档:
目的:
本文是《一种定位内存泄露的方法(Solaris)》对应的Linux版本,调试器使用gdb。主要介绍实例部分。其他请见《一种定位内存泄露的方法(Solaris)》。
实例:
模拟new失败的程序:
#include <stdexcept>
class ABC
{
public:
virtual ~ABC(){}
&nb ......
1 首先ORACLE_SID问题
[oracle@paopao ~]$ echo $ORACLE_SID
orcl
因为要创建的数据库名为orcl1,所以更改ORACLE_SID如下:
[oracle@paopao ~]$ export ORACLE_SID=orcl1
2 准备初始化参数文件
##########################################################################
####
# Copyright (c) 19 ......
linux中一共有32种信号,在/usr/include/bits/signum.h 头文件中可以看到
#define SIGHUP 1 /* Hangup (POSIX). */
#define SIGINT 2 /* Interrupt (ANSI).& ......
fg、bg、jobs、&、ctrl + z都是跟系统任务有关的,虽然现在基本上不怎么需要用到这些命令,但学会了也是很实用的
一。& 最经常被用到
这个用在一个命令的最后,可以把这个命令放到后台执行
二。ctrl + z
可以将一个正在前台执行的命令放到后台,并且暂停
三。jobs
& ......
1.下载linux kernel源代码
到http://www.kernel.org/下载linux内核源代码,这里我们使用2.6.24.4的内核.
解压linux-2.6.24.4.tar.bz2
[matt@localhost GEC2410]$ tar -xvjf linux-2.6.24.4.tar.bz2
[matt@localhost GEC2410]$ cd linux-2.6.24.4
2.修改Makefile,设置交叉编译器
ARCH ?= arm
CROSS_COMPILE ......